public ActionResult Create(LectorDto lector) { try { this.LectorService.Add(lector); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void Add(LectorDto lector) { if (lector == null) { throw new ArgumentNullException(nameof(lector)); } if (string.IsNullOrEmpty(lector.Name)) { throw new ArgumentException("Name should be filled", nameof(lector.Name)); } this.unitOfWork.Lector.Add(new Lector { Name = lector.Name, Surname = lector.Surname }); }