public HttpResponseMessage DUpdate_UserFundcenter_POManager_Mapping(UserupdtFundCenterMapping FundCentjson) { try { List <TEPOFundCenterUserMapping> FundVal = db.TEPOFundCenterUserMappings.Where(x => x.FundCenterId == FundCentjson.FundCentreCode && x.IsDeleted == false).ToList(); if (FundVal.Count > 0) { foreach (TEPOFundCenterUserMapping TEPOFUnd in FundVal) { TEPOFUnd.IsDeleted = true; TEPOFUnd.LastModifiedBy = FundCentjson.LastModifiedBy; TEPOFUnd.LastModifiedOn = DateTime.Now; db.Entry(TEPOFUnd).CurrentValues.SetValues(TEPOFUnd); db.SaveChanges(); } foreach (int Fund in FundCentjson.ManagerName) { if (Fund != 0 && !String.IsNullOrEmpty(Fund.ToString())) { TEPOFundCenterUserMapping TEPOFund = new TEPOFundCenterUserMapping(); TEPOFund.UserId = Fund; TEPOFund.FundCenterId = FundCentjson.FundCentreCode; TEPOFund.CreatedBy = FundCentjson.LastModifiedBy; TEPOFund.LastModifiedBy = FundCentjson.LastModifiedBy; TEPOFund.LastModifiedOn = DateTime.Now; TEPOFund.CreatedOn = DateTime.Now; TEPOFund.IsDeleted = false; db.TEPOFundCenterUserMappings.Add(TEPOFund); db.SaveChanges(); } } sinfo.errorcode = 0; sinfo.errormessage = "Updated Sucessfully"; sinfo.listcount = 0; return(new HttpResponseMessage() { Content = new JsonContent(new { info = sinfo }) }); } else { sinfo.errorcode = 1; sinfo.errormessage = "No Mapping DOne"; sinfo.listcount = 0; return(new HttpResponseMessage() { Content = new JsonContent(new { info = sinfo }) }); } } catch (Exception ex) { ExceptionObj.RecordUnHandledException(ex); sinfo.errorcode = 1; sinfo.errormessage = "Fail to Update"; sinfo.listcount = 0; return(new HttpResponseMessage() { Content = new JsonContent(new { info = sinfo }) }); } }
public HttpResponseMessage Add_UserFundcenter_POManager_Mapping(UserFundCenterMapping FundCentjson) { try { int FundCount = db.TEPOFundCenterUserMappings.Where(x => x.FundCenterId == FundCentjson.FundCenter && x.IsDeleted == false).Count(); if (FundCount == 0) { if (FundCentjson.MasterSubmitterlist.Count > 0) { foreach (MasterSubmitterlistModel Submitter in FundCentjson.MasterSubmitterlist.OrderBy(x => x.SequenceId).ToList()) { //if(Submitter.) TEPOFundCenterUserMapping TEPOFund = new TEPOFundCenterUserMapping(); TEPOFund.UserId = Submitter.SubmiterID; TEPOFund.FundCenterId = FundCentjson.FundCenter; TEPOFund.CreatedBy = FundCentjson.LastModifiedBy; TEPOFund.LastModifiedBy = FundCentjson.LastModifiedBy; TEPOFund.LastModifiedOn = DateTime.Now; TEPOFund.CreatedOn = DateTime.Now; TEPOFund.IsDeleted = false; db.TEPOFundCenterUserMappings.Add(TEPOFund); db.SaveChanges(); } sinfo.errorcode = 0; sinfo.errormessage = "Saved Sucessfully"; sinfo.listcount = 0; return(new HttpResponseMessage() { Content = new JsonContent(new { info = sinfo }) }); } else { sinfo.errorcode = 1; sinfo.errormessage = "No Submitters Present"; sinfo.listcount = 0; return(new HttpResponseMessage() { Content = new JsonContent(new { info = sinfo }) }); } } else { sinfo.errorcode = 1; sinfo.errormessage = "mapping has been Done for this FundCenter"; sinfo.listcount = 0; return(new HttpResponseMessage() { Content = new JsonContent(new { info = sinfo }) }); } } catch (Exception ex) { ExceptionObj.RecordUnHandledException(ex); sinfo.errorcode = 1; sinfo.errormessage = "Fail"; sinfo.listcount = 0; return(new HttpResponseMessage() { Content = new JsonContent(new { info = sinfo }) }); } }