public void Add(TypesCreateModel type) { if (!_typesRepository.Add(new Models.Type(type))) { throw new ApplicationException(); } }
public ActionResult Create(TypesCreateModel createModel) { if (!ModelState.IsValid) { return(View(createModel)); } try { _typesService.Add(createModel); } catch (Exception e) { return(new HttpStatusCodeResult(500, e.Message)); } return(RedirectToAction("Index")); }
public void Add_Valid_Test() { var model = new TypesCreateModel() { Description = "Tirowe" }; try { _typesService.Add(model); } catch { Assert.Fail(); return; } Assert.IsTrue(_applicationDbContext.Types.Any(t => t.Description.CompareTo(model.Description) == 0)); }
public void Add_Not_Valid_Test() { var model = new TypesCreateModel() { Description = "Tir" }; try { _typesService.Add(model); } catch { Assert.IsTrue(true); return; } Assert.Fail(); }
public Type(TypesCreateModel typesCreate) { Description = typesCreate.Description; }