public ActionResult Edit(Guid id) { try { var dbModel = _licenseService.Get(id.ToString()); if (dbModel != null) { var result = new CreateLicenseModel(dbModel); if (result != null) { return(View(result)); } } } catch (Exception ex) { _logger.Log(LogLevel.Error, ex); } return(Content("License not found")); }
public ActionResult Edit(CreateLicenseModel model) { try { if (!ModelState.IsValid) { return(View(model)); } if (_licenseService.Update(model.Id.ToString(), model.ToUpdateDbModel(_userService), UserId)) { return(Success()); } } catch (Exception ex) { _logger.Log(LogLevel.Error, ex); } ViewBag.ErrorMessage = "Възникна грешка!"; return(View(new CreateLicenseModel(model))); }
public ActionResult Create(CreateLicenseModel model) { try { if (!ModelState.IsValid) { return(View(model)); } var id = _licenseService.Create(model.ToDbModel(_userService), UserId); if (!string.IsNullOrEmpty(id)) { return(Success()); } } catch (Exception ex) { _logger.Log(LogLevel.Error, ex); } ViewBag.ErrorMessage = "Възникна грешка!"; return(View(new CreateLicenseModel(model))); }