public IActionResult Edit(CourtDuty model) { SetHelpFile(HelpFileValues.Nom8); if (!ModelState.IsValid) { return(View(nameof(Edit), model)); } string _isvalid = IsValid(model); if (_isvalid != string.Empty) { SetErrorMessage(_isvalid); return(View(nameof(Edit), model)); } var currentId = model.Id; if (service.CourtDuty_SaveData(model)) { this.SaveLogOperation(currentId == 0, model.Id); SetSuccessMessage(MessageConstant.Values.SaveOK); return(RedirectToAction(nameof(Index))); //return RedirectToAction(nameof(Edit), new { id = model.Id }); } else { SetErrorMessage(MessageConstant.Values.SaveFailed); } return(View(nameof(Edit), model)); }
/// <summary> /// Запис на Дежурства към съд /// </summary> /// <param name="model"></param> /// <returns></returns> public bool CourtDuty_SaveData(CourtDuty model) { try { if (model.Id > 0) { //Update var saved = repo.GetById <CourtDuty>(model.Id); saved.Label = model.Label; saved.Description = model.Description; saved.ActNomer = model.ActNomer; saved.ActDate = model.ActDate; saved.DateFrom = model.DateFrom; saved.DateTo = model.DateTo; repo.Update(saved); repo.SaveChanges(); } else { //Insert repo.Add <CourtDuty>(model); repo.SaveChanges(); //courtLoadPeriodService.GetLoadPeriod(null, model.Id); } return(true); } catch (Exception ex) { logger.LogError(ex, $"Грешка при запис на CourtDuty Id={ model.Id }"); return(false); } }
/// <summary> /// Добавяне на дежурство /// </summary> /// <returns></returns> public IActionResult Add() { var model = new CourtDuty() { CourtId = userContext.CourtId }; return(View(nameof(Edit), model)); }
/// <summary> /// Добавяне на дежурство /// </summary> /// <returns></returns> public IActionResult Add() { var model = new CourtDuty() { CourtId = userContext.CourtId, CheckCourtDutyLawUnits = service.FillCheckListVMs(userContext.CourtId, null).ToList() }; SetHelpFile(HelpFileValues.Nom8); return(View(nameof(Edit), model)); }
private string IsValid(CourtDuty model) { if (!model.CheckCourtDutyLawUnits.Any(x => x.Checked)) { return("Няма избрани съдии."); } if (model.DateTo != null && model.DateTo < model.DateFrom) { return("Дата до не може да е по малка от Дата от"); } return(string.Empty); }
public IActionResult Edit(CourtDuty model) { if (!ModelState.IsValid) { return(View(nameof(Edit), model)); } var currentId = model.Id; if (service.CourtDuty_SaveData(model)) { this.SaveLogOperation(currentId == 0, model.Id); SetSuccessMessage(MessageConstant.Values.SaveOK); return(RedirectToAction(nameof(Edit), new { id = model.Id })); } else { SetErrorMessage(MessageConstant.Values.SaveFailed); } return(View(nameof(Edit), model)); }