示例#1
0
 public void Add(TypesCreateModel type)
 {
     if (!_typesRepository.Add(new Models.Type(type)))
     {
         throw new ApplicationException();
     }
 }
示例#2
0
        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();
        }
示例#5
0
 public Type(TypesCreateModel typesCreate)
 {
     Description = typesCreate.Description;
 }