Example #1
0
        public ActionResult Create(EpeacUserViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var EpeacUser = _mapper.Map <EpeacUser>(model);
                var isSuccess = _repo.Create(EpeacUser);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something Went Wrong!");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something Went Wrong!");
                return(View(model));
            }
        }
Example #2
0
        public ActionResult Delete(int id, EpeacUserViewModel model)
        {
            try
            {
                // TODO: Add delete logic here
                var EpeacUser = _repo.FindById(id);
                if (EpeacUser == null)
                {
                    return(NotFound());
                }

                var isSuccess = _repo.Delete(EpeacUser);
                if (!isSuccess)
                {
                    return(View(model));
                }


                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(model));
            }
        }