Example #1
0
        public ActionResult Insert()
        {
            var model = new EndorsedLogoViewModel();

            model.Operation = "I";
            return(View("InsertEdit", model));
        }
Example #2
0
        public ActionResult InsertEdit(EndorsedLogoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                TempData["Error"] = "Transaction error";
                return(RedirectToAction("Index", "Sectors"));
            }
            var entity = _mapper.Map <EndorsedLogoViewModel, EndorsedLogoEntity>(model);

            entity.ImagePath = Server.MapPath("~/Content/img/Uploads/");
            var result = model.Operation == "E" ? _endorsedLogosManager.Update(entity) : _endorsedLogosManager.Insert(entity);

            TempData["Result"] = result;
            if (!result.Success)
            {
                return(RedirectToAction("Index"));
            }
            var operation = model.Operation == "E" ? "Edit Logo" : "Insert Logo";

            StoreLog("EndorsedLogos", operation, (int)result.Entity);
            return(RedirectToAction("Edit", new { id = (int)result.Entity }));
        }