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

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

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


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