Beispiel #1
0
        public void CreateAndDeleteDepartment()
        {
            // Идеально Имеет место создавать тестовую бд перед выполнением, а
            // мы сдеаем два теста в одном, но так делать нельзя с идеологической точки зрения, да и не только!!!
            // они НЕ ДОЛЖНЫ зависить друг от друга и проверять каждый должен конкретный свой аспект

            CatalogDepartmentDTO dto = new CatalogDepartmentDTO
            {
                Name          = "Else one more",
                EmployeeCount = 5,
            };
            Task <IBaseDTO> t = _service.Add("departments", dto);

            t.Wait();
            var newDto = t.Result as CatalogDepartmentDTO;

            Assert.IsNotNull(newDto, "Создание");

            Task <bool> t2 = _service.Delete("departments", newDto.Id);

            t2.Wait();
            bool result = t2.Result;

            Assert.IsTrue(result, "Удаление");
        }
        public ActionResult Add(Catalog catalog, HttpPostedFileBase image)
        {
            catalog.UserID = userService.GetByDefault(x => x.UserName == User.Identity.Name).ID;
            if (image == null)
            {
                catalogService.Add(catalog);
            }
            else
            {
                catalog.ImageUrl = new byte[image.ContentLength];
                image.InputStream.Read(catalog.ImageUrl, 0, image.ContentLength);
                catalogService.Add(catalog);
            }

            return(Redirect("/SysAdmin/Catalog/List"));
        }
Beispiel #3
0
        public ActionResult Create(CatalogEntryModel catalogEntryModel)
        {
            CatalogEntry entry = catalogEntryModel.ToServiceModel();

            if (ModelState.IsValid)
            {
                _catalogService.Add(entry);
                return(RedirectToAction("Index"));
            }
            catalogEntryModel.LicensingBases = _licenseTypeService.GetLicensingBases();
            return(View(catalogEntryModel));
        }