Exemplo n.º 1
0
        public void AddRegisterCategory(VmRegisterCategory vmRegisterCategory)
        {
            if (vmRegisterCategory == null)
            {
                throw new System.NullReferenceException("kayıt edilecek bilgi bulunamadı");
            }
            var tempCategory = vmRegisterCategory.GetCategory();

            database.Category.Add(tempCategory);
        }
        public static Category GetCategory(this VmRegisterCategory vmRegisterCategory)
        {
            var category = new Category()
            {
                CategoryName        = vmRegisterCategory.CategoryName,
                CategoryDescription = vmRegisterCategory.CategoryDescription,
                TimeOfCreation      = DateTime.Now,
                TimeOfModification  = DateTime.Now,
                IsActive            = true
            };

            return(category);
        }
Exemplo n.º 3
0
        public ActionResult Register(VmRegisterCategory vmRegisterCategory)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Eksik alanları doldurun...");
                return(View(vmRegisterCategory));
            }

            if (!categoryService.IsValidCategoryName(vmRegisterCategory.CategoryName))
            {
                ModelState.AddModelError("", "Bu kategori adı sisteme kayıtlıdır..");
                return(View(vmRegisterCategory));
            }



            categoryService.AddRegisterCategory(vmRegisterCategory);
            categoryService.SaveDb();


            return(RedirectToAction(nameof(Index)));
        }