TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Praveen Kumar
NA
235
22.2k
Value cannot be null" Parameter Name:source
Jul 15 2020 2:11 AM
Hi
I am getting error "Value cannot be null" Parameter Name:source"
Addaccount.cshtml
@model Redi2.RMIM.Web.Areas.AccountSetup.Models.AccountDetailViewModel
@section DevExtremeBundles
{
@Styles.Render(
"~/Content/DevExtremeBundle"
)
@Scripts.Render(
"~/Scripts/DevExtremeBundle"
)
}
<div
class
=
"modal-header"
>
<h4
class
=
"modal-title"
id=
"myModalLabel"
>Account Details</h4>
<button type=
"button"
class
=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span aria-hidden=
"true"
>×</span>
</button>
</div>
@using (Html.BeginForm(
"AddAccountModal"
,
"Manage"
,
new
{ Area =
"Client"
}, FormMethod.Post,
new
{ @
class
=
"form-horizontal"
, id =
"addAccountModalForm"
}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(
true
,
""
,
new
{ @
class
=
"text-danger"
})
@Html.HiddenFor(model => model.Account.Id)
@Html.HiddenFor(model => model.Client.ParentId)
<div
class
=
"modal-body"
>
<div
class
=
"box box-solid"
>
<div
class
=
"box-header"
>
<h5
class
=
"box-title"
>Account Infomation:</h5>
</div>
<div
class
=
"box-body"
>
<div
class
=
"form-group row"
>
<!-- /.col-lg-6 -->
@Html.LabelFor(model => model.Account.Name,
new
{ @
class
=
"col-sm-5 control-label"
, @required =
"required"
})
<div
class
=
"col-sm-5"
>
@Html.EditorFor(model => model.Account.Name)
@Html.ValidationMessageFor(model => model.Account.Name,
""
,
new
{ @
class
=
"text-danger"
})
</div>
</div>
<div
class
=
"form-group row"
>
@Html.LabelFor(model => model.Account.Number,
new
{ @
class
=
"col-sm-5 control-label"
, @required =
"required"
})
<div
class
=
"col-sm-5"
>
@Html.EditorFor(model => model.Account.Number)
@Html.ValidationMessageFor(model => model.Account.Number,
""
,
new
{ @
class
=
"text-danger"
})
</div>
</div>
<div
class
=
"form-group row"
>
@Html.LabelFor(model => model.Account.Description,
new
{ @
class
=
"col-sm-5 control-label"
})
<div
class
=
"col-sm-5"
>
@Html.EditorFor(model => model.Account.Description)
</div>
</div>
<div
class
=
"form-group row"
>
@Html.LabelFor(model => model.Account.StartDate,
new
{ @
class
=
"col-sm-5 control-label"
})
<div
class
=
"col-sm-4"
>
@(Html.DevExtreme().DateBoxFor(m => m.Account.StartDate)
.ID(
"AccountStartDate"
)
.DisplayFormat(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
.Placeholder(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
.ShowClearButton(
false
)
.InvalidDateMessage(
"The date must have the following format: "
+ System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
)
@Html.ValidationMessageFor(model => model.Account.StartDate,
""
,
new
{ @
class
=
"text-danger"
})
</div>
</div>
</div>
</div>
<h5
class
=
"info-text"
style=
"text-align:center"
>
Does
this
account have portfolios?
@*<input id=
"toggle-portfolios"
type=
"checkbox"
data-toggle=
"toggle"
data-on=
"Yes"
data-off=
"No"
data-onstyle=
"success"
data-offstyle=
"danger"
style=
"margin-left:10px;"
>*@
<input type=
"button"
class
=
"btn btn-success"
id=
"btnYes"
onclick=
"toggleOn()"
value=
"Yes"
>
<input type=
"button"
class
=
"btn btn-danger"
id=
"btnNo"
onclick=
"toggleOff()"
value=
"No"
>
</h5>
<div
class
=
"portfoliosForm"
>
<div
class
=
"form-horizontal"
>
<div
class
=
"row1"
>
<div
class
=
"box box-solid"
>
<div
class
=
"box-header"
>
</div>
<div
class
=
"box-body"
>
<div
class
=
"form-group row"
>
<h5
class
=
"col-sm-5"
style=
"text-align:right"
>Choose an existing product</h5>
<div
class
=
"col-sm-5"
>
@(Html.LabelFor(m => m.ProductId))<br>
@(Html.DropDownListFor(m => m.ProductId,
new
SelectList(Model.DDLProducts.OrderBy(x => x.Text),
"Value"
,
"Text"
),
"Please Select..."
,
new
{ @
class
=
"form-control"
, @id =
"ddlProduct"
}))
</div>
</div>
<div
class
=
"form-group row"
>
@*@Html.LabelFor(model => model.InvetsmentDate,
new
{ @
class
=
"col-sm-5 control-label"
})*@
<h5
class
=
"col-sm-5"
style=
"text-align:right"
>Start date</h5>
<div
class
=
"col-sm-5"
>
@(Html.DevExtreme().DateBoxFor(m => m.InvetsmentDate)
.ID(
"InvestmentStartDate"
)
.DisplayFormat(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
.Placeholder(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
.ShowClearButton(
false
)
.InvalidDateMessage(
"The date must have the following format: "
+ System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
)
@Html.ValidationMessageFor(model => model.InvetsmentDate,
""
,
new
{ @
class
=
"text-danger"
})
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class
=
"modal-footer"
>
<button type=
"submit"
class
=
"btn btn-primary"
id=
"submitAccountEdit"
>Save</button>
<button type=
"button"
class
=
"btn btn-primary"
data-dismiss=
"modal"
>Cancel</button>
</div>
}
@Scripts.Render(
"~/bundles/jqueryval"
)
@Scripts.Render(
"~/bundles/wizard"
)
<script>
$(document).ready(
function
() {
$(
'.portfoliosForm'
).hide();
});
</script>
<script>
function
toggleOn() {
$(
'.portfoliosForm'
).css(
"display"
,
"block"
);
}
function
toggleOff() {
$(
'.portfoliosForm'
).css(
"display"
,
"none"
);
}
</script>
Controller
[HttpGet]
public
ActionResult AddAccountModal(
int
clientId)
{
if
(_logger.IsInfoEnabled)
_logger.LogInfo(string.Format(
"Entering AddAccountModal with ID {0}"
, clientId));
using (
var
dbContextScope = _dbContextScopeFactory.CreateReadOnly())
{
// Only coded for adding new accounts right now
AccountSetup.Models.AccountDetailViewModel model =
new
AccountSetup.Models.AccountDetailViewModel()
{
Account =
new
AccountSetup.Models.OrganizationViewModel()
{
StartDate = DateTime.Now.Date
},
Client =
new
AccountSetup.Models.OrganizationHierarchyViewModel()
{
ParentId = clientId
},
DDLProducts = SelectListItemHelper.Organizations(GetCustomerId(),
"PR"
),
InvetsmentDate = DateTime.Now.Date
};
if
(_logger.IsInfoEnabled)
_logger.LogInfo(
"Exiting AddAccountModal"
);
return
PartialView(model);
}
}
[HttpPost]
[ValidateAntiForgeryToken]
public
ActionResult AddAccountModal(AccountSetup.Models.AccountDetailViewModel model)
{
using
(var dbContextScope = _dbContextScopeFactory.Create())
{
User user = _Login.GetCurrentUser();
AccountValidationController accountValidation =
new
AccountValidationController();
// Edit not yet implemented!
var isEdit = model.Account.Id > 0;
if
(isEdit)
{
var acct = _AcRepo.GetAccount(model.Account.Id, user);
acct.Name = model.Account.Name;
acct.OrganizationNumber = model.Account.Number;
acct.Description = model.Account.Description;
var errorMsg = accountValidation.CheckOrgForDuplicatesNameAndNumber(acct,
"AC"
, _Login.GetCurrentUserCustomer().Id);
if
(errorMsg.Count > 0)
{
errorMsg.ForEach(m =>
{
ModelState.AddModelError(
""
, m);
});
return
PartialView(
"AddAccountModal"
, model);
}
if
(acct.StartDate != model.Account.StartDate)
{
// if changing then start date must be before first fee
DateTime firstFeeDate = model.Account.StartDate;
var feeRepo =
new
FeeRepository(_ambientDbContextLocator);
var fees = feeRepo.GetActiveFeesForAccount(acct.Id);
if
(fees.Any())
{
firstFeeDate = fees.First().PeriodStartDate.Value;
}
if
(model.Account.StartDate > firstFeeDate)
{
ModelState.AddModelError(
""
,
"Account has already been billed. Start Date must be on or before "
+ firstFeeDate.ToShortDateString());
return
PartialView(
"EditAccountModal"
, model);
}
var userId = _Login.GetCurrentUser().UserId;
var now = DateTime.Now;
// if moving earlier, then update start date of account-level attributes
if
(model.Account.StartDate < acct.StartDate)
UpdateAttributesStartDate(acct.UserCodeValues, model.Account.StartDate, userId, now,
"EditAccountModal"
);
else
// if moving later, then update start date of investment, account-level attributes, investment-level attributes, and participants
{
UpdateAttributesStartDate(acct.UserCodeValues, model.Account.StartDate, userId, now,
"EditAccountModal"
);
PropagateStartDate(acct, model.Account.StartDate, userId, now,
"EditAccountModal"
);
}
_AcRepo.AddAuditNote(
"Updating start date for account "
+ acct.GetDisplay() +
"."
, acct, user);
acct.StartDate = model.Account.StartDate;
acct.StatusCode = OrgStatus.P.SmartCode;
// set to Pending
}
if
(model.Client.ParentId != 0)
{
OrganizationHierarchy client = _AcRepo.GetClientByAccount(acct.Id);
if
(client ==
null
)
{
client =
new
OrganizationHierarchy
{
ParentOrganizationId = model.Client.ParentId,
ChildOrganizationId = acct.Id,
StartDate = acct.StartDate,
StatusCode =
"A"
};
_AcRepo.AddOrganizationHierarchy(client, user);
}
else
{
if
(client.ParentOrganizationId != model.Client.ParentId)
{
client.ParentOrganizationId = model.Client.ParentId;
}
}
}
//acct.Name = model.Account.Name;
//acct.OrganizationNumber = model.Account.Number;
//acct.Description = model.Account.Description;
//_AcRepo.SaveAccount(acct, _Login.GetCurrentUser());
_AcRepo.UpdateWithUser(acct, user.UserId,
"AddAccountModal"
);
}
else
{
if
(!ModelState.IsValid)
{
return
PartialView(
"AddAccountModal"
, model);
}
var acct =
new
Organization()
{
Name = model.Account.Name,
OrganizationNumber = model.Account.Number,
Description = model.Account.Description,
StartDate = model.Account.StartDate,
StatusCode =
"P"
,
CustomerId = GetCustomerId(),
TypeCode =
"AC"
,
OrganizationTypeId = _AcRepo.FindByDetached<OrganizationType>(o => o.OrganizationTypeCode ==
"AC"
).FirstOrDefault().Id
};
var errorMsg = accountValidation.CheckOrgForDuplicatesNameAndNumber(acct,
"AC"
, _Login.GetCurrentUserCustomer().Id);
if
(errorMsg.Count > 0)
{
errorMsg.ForEach(m =>
{
ModelState.AddModelError(
""
, m);
});
model.DDLProducts = SelectListItemHelper.Organizations(acct.CustomerId,
"PR"
);
return
PartialView(
"AddAccountModal"
, model);
}
var clientOH =
new
OrganizationHierarchy
{
ParentOrganizationId = model.Client.ParentId,
Child = acct,
StartDate = acct.StartDate,
StatusCode =
"A"
};
var client = _AcRepo.FindByDetached<Organization>(o => o.Id == model.Client.ParentId).First();
_AcRepo.AddOrganizationHierarchy(clientOH, user);
_AcRepo.AddWithUser(acct, user.UserId,
"AddAccountModal"
);
if
(model.ProductId !=
null
)
{
Organization portfolio = _AcRepo.GetProductByProductId((
int
)model.ProductId, GetCustomerId());
var product =
new
Organization()
{
Name = portfolio.Name,
OrganizationNumber = portfolio.OrganizationNumber,
Description = portfolio.Description,
StartDate = model.InvetsmentDate,
StatusCode =
"P"
,
CustomerId = GetCustomerId(),
TypeCode = portfolio.TypeCode,
OrganizationTypeId = _AcRepo.FindByDetached<OrganizationType>(o => o.OrganizationTypeCode ==
"PR"
).FirstOrDefault().Id
};
Organization organizationExist = _AcRepo.GetOrganizationByUniqueIndex(portfolio.Name,
"PR"
, product.CustomerId, portfolio.OrganizationNumber);
OrganizationHierarchy oh =
null
;
if
(organizationExist ==
null
)
{
oh =
new
OrganizationHierarchy
{
Parent = acct,
Child = product,
StartDate = product.StartDate,
StatusCode =
"A"
};
}
else
{
oh =
new
OrganizationHierarchy
{
Parent = acct,
Child = organizationExist,
StartDate = product.StartDate,
StatusCode =
"A"
};
}
_AcRepo.AddOrganizationHierarchy(oh, user);
if
(organizationExist ==
null
)
{
_AcRepo.AddWithUser(product, user.UserId,
"AddAccountModal"
);
}
}
else
{
//Create a default product
var defaultProduct =
new
Organization()
{
Name = acct.Name,
OrganizationNumber = acct.OrganizationNumber,
Description = acct.Description,
StartDate = acct.StartDate,
StatusCode =
"P"
,
CustomerId = GetCustomerId(),
TypeCode =
"PR"
,
OrganizationTypeId = _AcRepo.FindByDetached<OrganizationType>(o => o.OrganizationTypeCode ==
"PR"
).FirstOrDefault().Id
};
Organization organizationExist = _AcRepo.GetOrganizationByUniqueIndex(defaultProduct.Name,
"PR"
, defaultProduct.CustomerId, defaultProduct.OrganizationNumber);
OrganizationHierarchy oh =
null
;
if
(organizationExist ==
null
)
{
oh =
new
OrganizationHierarchy
{
Parent = acct,
Child = defaultProduct,
StartDate = defaultProduct.StartDate,
StatusCode =
"A"
};
}
else
{
oh =
new
OrganizationHierarchy
{
Parent = acct,
Child = organizationExist,
StartDate = defaultProduct.StartDate,
StatusCode =
"A"
};
}
_AcRepo.AddOrganizationHierarchy(oh, user);
if
(organizationExist ==
null
)
{
_AcRepo.AddWithUser(defaultProduct, user.UserId,
"AddAccountModal"
);
}
}
DoAuditableChange(
"Adding account "
+ acct.GetDisplay(), client, user);
}
dbContextScope.SaveChanges();
}
return
Json(
new
{ success =
true
});
}
Reply
Answers (
11
)
Load Balancer in .Net
i create pdf from rotativa in mvc .