예제 #1
0
        //
        // GET: DelegationCategory/Edit/5
        public IActionResult Edit(int id)
        {
            try
            {
                if (_dbContext.DelegationCategory.Any(d => d.Id == id))
                {
                    DelegationCategory delegationCategory = _dbContext.DelegationCategory.Where(d => d.Id == id).First();
                    return(View(delegationCategory));
                }
            }
            catch { }

            return(View("Error"));
        }
예제 #2
0
        //
        // GET: DelegationCategory/Delete/5
        public IActionResult Delete(int id)
        {
            try
            {
                if (_dbContext.DelegationCategory.Any(d => d.Id == id))
                {
                    DelegationCategory delegationCategory = _dbContext.DelegationCategory.Where(d => d.Id == id).First();
                    _dbContext.DelegationCategory.Remove(delegationCategory);
                    _dbContext.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch { }

            return(View("Error"));
        }
예제 #3
0
        public IActionResult Edit(int id, DelegationCategory model)
        {
            try
            {
                if (_dbContext.DelegationCategory.Any(d => d.Id == id))
                {
                    DelegationCategory delegationCategory = _dbContext.DelegationCategory.Where(d => d.Id == id).First();
                    delegationCategory.Name = model.Name;
                    _dbContext.DelegationCategory.Update(delegationCategory);
                    _dbContext.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch { }

            return(View("Error"));
        }
예제 #4
0
        public IActionResult Create(DelegationCategory model)
        {
            if (model == null)
            {
                return(View("Error"));
            }

            try
            {
                _dbContext.DelegationCategory.Add(new DelegationCategory()
                {
                    Name = model.Name
                });
                _dbContext.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch { }
            return(View("Error"));
        }