Example #1
0
        public ActionResult Create(CreativityPhraseViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var CreativityPhrase = _mapper.Map <CreativityPhrase>(model);
                var isSuccess        = _repo.Create(CreativityPhrase);
                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, CreativityPhraseViewModel model)
        {
            try
            {
                // TODO: Add delete logic here
                var CreativityPhrase = _repo.FindById(id);
                if (CreativityPhrase == null)
                {
                    return(NotFound());
                }

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


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