public Boolean Save() { try { int new_id = ++context.EdpmCountries.OrderBy(a => a.Id).ToList().Last().Id; var x = new EdpmCountries { Id = new_id, Type = mType, Description = mDescription, Country = mCountry }; context.EdpmCountries.Add(x); context.SaveChanges(); return(true); } catch (Exception x) { throw (x); } }
public Boolean Save() { try { int new_id = ++context.EdpmSectors.OrderBy(a => a.Id).ToList().Last().Id; var x = new EdpmSectors { Id = new_id, Sector = mSector, Description = mDescription, DirectorateId = mDirectorateId }; context.EdpmSectors.Add(x); context.SaveChanges(); return(true); } catch (Exception x) { throw (x); } }
public Boolean UpdateProgressiveInformation() { try { var decision = GetRecordByKey(mDecisionID); if (decision != null) { saveLog(decision.Id, System.Convert.ToInt32(decision.StatusId), decision.StatusNarrative, decision.Comments); decision.Id = System.Convert.ToInt32(mDecisionID); decision.StatusId = mImplementationStatusID; decision.StatusNarrative = mImplementationStatusNarrative; decision.StatusComments = mStatusComments; decision.StatusIdUpdatedBasedOnPartnerState = false; context.SaveChanges(); } return(true); } catch (Exception x) { throw (x); } }
public ActionResult BatchUpdateActivities([FromBody] CRUDModel <spView_admin_strategicplansearchGetAll_Result> value) { //var recordssaved = 0; if (value.Changed != null && value.Changed.Count() > 0) { foreach (var temp in value.Changed) { var exist = context.SpActivity.FirstOrDefault(o => o.SpAActivityCode == temp.sp_a_activity_code); SpActivityLog existlog = new SpActivityLog(); //var existlog = context.SpActivityLog.FirstOrDefault(o => o.ActivityLogCode == temp.sp_a_activity_code); if (exist != null) { if (string.IsNullOrEmpty(existlog.ActivityLogCode.ToString()) || existlog.ActivityLogCode == 0) { var newCode = NewCodeLog(); existlog.ActivityLogCode = ++newCode; } //Save Old Record existlog.SpAStrategyCode = Convert.ToInt32(exist.SpAStrategyCode); existlog.SpAActivity = exist.SpAActivity; existlog.SpAOutput = exist.SpAOutput; existlog.SpATimeframeYear = Convert.ToInt32(exist.SpATimeframeCode); existlog.SpATimeframeYear = Convert.ToInt32(exist.SpATimeframeYear); existlog.SpAPerformanceIndicator = exist.SpAPerformanceIndicator; existlog.SpAEstimatedCostMillions = exist.SpAEstimatedCostMillions; existlog.SpAIsVisible = exist.SpAIsVisible; existlog.Deleted = exist.Deleted; //Into New existlog.SpAStrategyCodeNew = Convert.ToInt32(temp.sp_a_strategy_code); existlog.SpAActivityNew = temp.sp_a_activity; existlog.SpAOutputNew = temp.sp_a_output; existlog.SpATimeframeCodeNew = Convert.ToInt32(temp.sp_a_timeframe_code); existlog.SpATimeframeYearNew = Convert.ToInt32(temp.sp_a_timeframe_year); existlog.SpAPerformanceIndicatorNew = temp.sp_a_performance_Indicator; existlog.SpAEstimatedCostMillionsNew = temp.sp_a_estimated_cost_millions; existlog.SpAIsVisibleNew = temp.sp_a_is_visible; //existlog.Deleted = temp.Deleted; context.SpActivityLog.Add(existlog); context.SaveChanges(); //Save into sp_activity exist.SpAStrategyCode = Convert.ToInt32(temp.sp_a_strategy_code); exist.SpAActivity = temp.sp_a_activity; exist.SpAOutput = temp.sp_a_output; exist.SpATimeframeCode = Convert.ToInt32(temp.sp_a_timeframe_code); exist.SpATimeframeYear = Convert.ToInt32(temp.sp_a_timeframe_year); exist.SpAPerformanceIndicator = temp.sp_a_performance_Indicator; exist.SpAEstimatedCostMillions = temp.sp_a_estimated_cost_millions; exist.SpAIsVisible = temp.sp_a_is_visible; exist.Deleted = temp.Deleted; context.Entry(exist).State = EntityState.Modified;//Update record in original table context.SaveChanges(); } //return Json(value.Value); //return Content("") /*RedirectToAction("DataSourceCommonMarket")*/; } } return(Json(value.Value)); }
public ActionResult BatchUpdateActFinYear([FromBody] CRUDModel <spView_AWP_FinancialYear_ActivitysearchGetAll_Result> value) { var recordssaved = 0; if (value.Changed != null && value.Changed.Count() > 0) { foreach (var temp in value.Changed) { var exist = context.AwpFinancialYearActivity.FirstOrDefault(o => (o.FinancialYearCode == Convert.ToInt32(temp.financial_year_code)) && (o.AwpActivityCode == temp.awp_activity_code)); var existlog = context.AwpFinancialYearActivityLog.FirstOrDefault(o => (o.ActivityLogCode == temp.awp_activity_code)); if (exist != null) { exist.January = temp._January; exist.February = temp._February; exist.March = temp._March; exist.April = temp._April; exist.May = temp._May; exist.June = temp._June; exist.July = temp._July; exist.August = temp._August; exist.September = temp._September; exist.October = temp._October; exist.November = temp._November; exist.December = temp._December; exist.ValueJanuary = temp.value_January; exist.ValueFebruary = temp.value_February; exist.ValueMarch = temp.value_March; exist.ValueApril = temp.value_April; exist.ValueMay = temp.value_May; exist.ValueJune = temp.value_June; exist.ValueJuly = temp.value_July; exist.ValueAugust = temp.value_August; exist.ValueSeptember = temp.value_September; exist.ValueOctober = temp.value_October; exist.ValueNovember = temp.value_November; exist.ValueDecember = temp.value_December; exist.ArchievementJanuary = temp.archievement_January; exist.ArchievementFebruary = temp.archievement_February; exist.ArchievementMarch = temp.archievement_March; exist.ArchievementApril = temp.archievement_April; exist.ArchievementMay = temp.archievement_May; exist.ArchievementJune = temp.archievement_June; exist.ArchievementJuly = temp.archievement_July; exist.ArchievementAugust = temp.archievement_August; exist.ArchievementSeptember = temp.archievement_September; exist.ArchievementOctober = temp.archievement_October; exist.ArchievementNovember = temp.archievement_November; exist.ArchievementDecember = temp.archievement_December; exist.Budget000 = temp.Budget_000; exist.FunderCode = Convert.ToInt32(temp.funder_code); exist.IsVisible = temp.is_visible; exist.Deleted = false; context.Entry(exist).State = EntityState.Modified;//Update record in original table if (existlog != null) { existlog.FinancialYearCode = Convert.ToInt32(temp.financial_year_code); existlog.AwpActivityCode = temp.awp_activity_code; existlog.January = temp._January; existlog.February = temp._February; existlog.March = temp._March; existlog.April = temp._April; existlog.May = temp._May; existlog.June = temp._June; existlog.July = temp._July; existlog.August = temp._August; existlog.September = temp._September; existlog.October = temp._October; existlog.November = temp._November; existlog.December = temp._December; existlog.ValueJanuary = temp.value_January; existlog.ValueFebruary = temp.value_February; existlog.ValueMarch = temp.value_March; existlog.ValueApril = temp.value_April; existlog.ValueMay = temp.value_May; existlog.ValueJune = temp.value_June; existlog.ValueJuly = temp.value_July; existlog.ValueAugust = temp.value_August; existlog.ValueSeptember = temp.value_September; existlog.ValueOctober = temp.value_October; existlog.ValueNovember = temp.value_November; existlog.ValueDecember = temp.value_December; existlog.ArchievementJanuary = temp.archievement_January; existlog.ArchievementFebruary = temp.archievement_February; existlog.ArchievementMarch = temp.archievement_March; existlog.ArchievementApril = temp.archievement_April; existlog.ArchievementMay = temp.archievement_May; existlog.ArchievementJune = temp.archievement_June; existlog.ArchievementJuly = temp.archievement_July; existlog.ArchievementAugust = temp.archievement_August; existlog.ArchievementSeptember = temp.archievement_September; existlog.ArchievementOctober = temp.archievement_October; existlog.ArchievementNovember = temp.archievement_November; existlog.ArchievementDecember = temp.archievement_December; existlog.Budget000 = temp.Budget_000; existlog.FunderCode = Convert.ToInt32(temp.funder_code); existlog.IsVisible = temp.is_visible; existlog.Deleted = false; existlog.UpdatedBy = userInfor.GetUser().Identity.Name; existlog.UpdatedDate = DateTime.Now; context.Entry(existlog).State = EntityState.Modified; //Update record in log table } else if (existlog == null) { AwpFinancialYearActivityLog activitylog = new AwpFinancialYearActivityLog(); if (string.IsNullOrEmpty(activitylog.ActivityLogCode.ToString()) || activitylog.ActivityLogCode == 0) { var newCode = FinYearActLogCode(); activitylog.ActivityLogCode = ++newCode; } activitylog.FinancialYearCode = Convert.ToInt32(temp.financial_year_code); activitylog.AwpActivityCode = temp.awp_activity_code; activitylog.January = temp._January; activitylog.February = temp._February; activitylog.March = temp._March; activitylog.April = temp._April; activitylog.May = temp._May; activitylog.June = temp._June; activitylog.July = temp._July; activitylog.August = temp._August; activitylog.September = temp._September; activitylog.October = temp._October; activitylog.November = temp._November; activitylog.December = temp._December; activitylog.ValueJanuary = temp.value_January; activitylog.ValueFebruary = temp.value_February; activitylog.ValueMarch = temp.value_March; activitylog.ValueApril = temp.value_April; activitylog.ValueMay = temp.value_May; activitylog.ValueJune = temp.value_June; activitylog.ValueJuly = temp.value_July; activitylog.ValueAugust = temp.value_August; activitylog.ValueSeptember = temp.value_September; activitylog.ValueOctober = temp.value_October; activitylog.ValueNovember = temp.value_November; activitylog.ValueDecember = temp.value_December; activitylog.ArchievementJanuary = temp.archievement_January; activitylog.ArchievementFebruary = temp.archievement_February; activitylog.ArchievementMarch = temp.archievement_March; activitylog.ArchievementApril = temp.archievement_April; activitylog.ArchievementMay = temp.archievement_May; activitylog.ArchievementJune = temp.archievement_June; activitylog.ArchievementJuly = temp.archievement_July; activitylog.ArchievementAugust = temp.archievement_August; activitylog.ArchievementSeptember = temp.archievement_September; activitylog.ArchievementOctober = temp.archievement_October; activitylog.ArchievementNovember = temp.archievement_November; activitylog.ArchievementDecember = temp.archievement_December; activitylog.Budget000 = temp.Budget_000; activitylog.FunderCode = Convert.ToInt32(temp.funder_code); activitylog.IsVisible = temp.is_visible; activitylog.Deleted = false; activitylog.UpdatedBy = userInfor.GetUser().Identity.Name; activitylog.UpdatedDate = DateTime.Now; context.AwpFinancialYearActivityLog.Add(activitylog); context.SaveChanges(); //Throws an error here } } else { // context.AwpFinancialYearActivity.Add(temp); } } recordssaved += context.SaveChanges(); } //return Json(value); return(Content("") /*RedirectToAction("DataSourceCommonMarket")*/); }
public ActionResult BatchUpdatePerConYear([FromBody] CRUDModel <ViewPcCriteriaFinancialYear> value) { var recordssaved = 0; if (value.Changed != null && value.Changed.Count() > 0) { foreach (var temp in value.Changed) { var exist = context.PcCriteriaFinancialYear.FirstOrDefault(o => (o.FinancialYearCode == temp.FinancialYearCode) && (o.PcCriteriaCode == temp.PcCriteriaCode)); var existlog = context.PcCriteriaFinancialYearLog.FirstOrDefault(o => o.FinancialYearCodeLog == temp.PcCriteriaCode); if (exist != null) { exist.PcActualValue = temp.PcActualValue; exist.PcTargetValue = temp.PcTargetValue; exist.PcComment = temp.PcComment; exist.IsVisible = temp.IsVisible; context.Entry(exist).State = EntityState.Modified; if (existlog != null) { PcCriteriaFinancialYearLog activitynotnulllog = new PcCriteriaFinancialYearLog(); if (string.IsNullOrEmpty(activitynotnulllog.FinancialYearCodeLog.ToString()) || activitynotnulllog.FinancialYearCodeLog == 0) { var newCode = PcCriteriafinyearCodeLog(); activitynotnulllog.FinancialYearCodeLog = ++newCode; } activitynotnulllog.FinancialYearCode = temp.FinancialYearCode; activitynotnulllog.PcCriteriaCode = temp.PcCriteriaCode; activitynotnulllog.PcActualValue = temp.PcActualValue; activitynotnulllog.PcTargetValue = temp.PcTargetValue; activitynotnulllog.PcComment = temp.PcComment; activitynotnulllog.IsVisible = temp.IsVisible; activitynotnulllog.EditedBy = userInfor.GetUser().Identity.Name; activitynotnulllog.EditedDate = DateTime.Now; context.Entry(activitynotnulllog).State = EntityState.Modified; //Update record in log table context.SaveChanges(); } else if (existlog == null) { PcCriteriaFinancialYearLog activitynulllog = new PcCriteriaFinancialYearLog(); if (string.IsNullOrEmpty(activitynulllog.FinancialYearCodeLog.ToString()) || activitynulllog.FinancialYearCodeLog == 0) { var newCode = PcCriteriafinyearCodeLog(); activitynulllog.FinancialYearCodeLog = ++newCode; } activitynulllog.FinancialYearCode = temp.FinancialYearCode; activitynulllog.PcCriteriaCode = temp.PcCriteriaCode; activitynulllog.PcActualValue = temp.PcActualValue; activitynulllog.PcTargetValue = temp.PcTargetValue; activitynulllog.PcComment = temp.PcComment; activitynulllog.IsVisible = temp.IsVisible; activitynulllog.EditedBy = userInfor.GetUser().Identity.Name; activitynulllog.EditedDate = DateTime.Now; context.PcCriteriaFinancialYearLog.Add(activitynulllog); context.SaveChanges(); //Throws an error here } } //else //{ // context.AwpFinancialYearActivity.Add(temp); //} } recordssaved += context.SaveChanges(); } //return Json(value); return(Content("") /*RedirectToAction("DataSourceCommonMarket")*/); }