Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Private,GroupCategory,IconPath")] GroupDescription groupDescription)
        {
            if (id != groupDescription.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _db.Update(groupDescription);
                    _db.Save();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupDescriptionExists(groupDescription.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupCategory"] = new SelectList(_db.GetCategories(), "Id", "Name", groupDescription.GroupCategory);
            return(View(groupDescription));
        }
Example #2
0
        public bool EditGroupInfo(GroupDescription model)
        {
            GroupDescription group = _groupRepo.GetElement(model.Id);
            var elem = _groupRepo.GetElementByName(model.Name);

            if (elem == null)
            {
                group.Name = model.Name;
            }
            else if (model.Name != group.Name)
            {
                return(false);
            }

            group.Private = model.Private;
            _groupRepo.Update(group);
            _groupRepo.Save();
            return(true);
        }