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 }) }); } }