public IActionResult Edit(CourtHall model) { if (!ModelState.IsValid) { SetViewBag(); return(View(nameof(Edit), model)); } string _isvalid = IsValid(model); if (_isvalid != string.Empty) { SetErrorMessage(_isvalid); SetViewBag(); return(View(nameof(Edit), model)); } var currentId = model.Id; if (service.CourtHall_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); } SetViewBag(); return(View(nameof(Edit), model)); }
/// <summary> /// Добавяне на зала /// </summary> /// <returns></returns> public IActionResult Add() { var model = new CourtHall() { CourtId = userContext.CourtId, DateFrom = DateTime.Now }; return(View(nameof(Edit), model)); }
/// <summary> /// Валидация преди запис на зала /// </summary> /// <param name="model"></param> /// <returns></returns> private string IsValid(CourtHall model) { if (string.IsNullOrEmpty(model.Name)) { return("Въведете име"); } if (model.DateFrom == null) { return("Въведете дата от"); } return(string.Empty); }
private bool migrate_CourtHall(MigrationData item) { var data = item.Data.Split('|'); try { var model = new CourtHall() { CourtId = item.CourtId, Name = data[0], Location = data[1], DateFrom = DefaultDateFrom }; repo.Add(model); repo.SaveChanges(); return(true); } catch (Exception ex) { var error = ex.Message; return(false); } }