Esempio n. 1
0
        public async Task <IActionResult> EditCategories(EditModels model)
        {
            var categories = await _context.Categories.OrderBy(i => i.Name).ToListAsync();

            if (ModelState.IsValid)
            {
                if (categories.All(i => i.Name != model.CategoryName))
                {
                    var category = new Category
                    {
                        Name = model.CategoryName
                    };
                    await _context.Categories.AddAsync(category);

                    await _context.SaveChangesAsync();

                    categories.Add(category);
                }
                else
                {
                    ModelState.AddModelError("CategoryName", "This name is already exist");
                }
            }

            ViewBag.Categories = categories;

            return(View(model));
        }
Esempio n. 2
0
 private void MemberEditProc()
 {
     IsEditingMembers = true;
     EditModels.Clear();
     foreach (var member in SelectedHousehold.Members)
     {
         EditModels.Add(new PersonEditModel(member.Model));
     }
 }