Ejemplo n.º 1
0
        public ActionResult Add(MedidaCrudViewModel model)
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddMedida Controller Begin"));

            try
            {
                // Add add logic here
                if (ModelState.IsValid)
                {
                    var committed = _serviceMedida.Insert(model.Medida, null);
                    _unitOfWork.SaveChanges();
                    if (committed)
                    {
                        //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddMedida Controller End"));
                        return(RedirectToAction("Add"));
                    }
                }
            }
            catch (Exception ex)
            {
                //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddMedida Controller ERROR"), ex);
            }

            ModelState.AddModelError("", PresentationResources.Error);
            return(View("MedidaAddView", new MedidaCrudViewModel(_serviceMedida, _serviceFactConv)));
        }
Ejemplo n.º 2
0
        // GET
        public ActionResult Add()
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddMedida Controller Begin"));

            try
            {
                // Add add logic here
                var model = new MedidaCrudViewModel(_serviceMedida, _serviceFactConv);

                //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddMedida Controller End"));
                return(View("MedidaAddView", model));
            }
            catch (Exception ex)
            {
                //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - AddMedida Controller ERROR"), ex);
            }

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 3
0
        // GET
        public ActionResult Remove(int id)
        {
            //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - RemoveMedida Controller Begin"));

            try
            {
                // Add remove logic here
                var model = new MedidaCrudViewModel(_serviceMedida, _serviceFactConv)
                {
                    Medida = _serviceMedida.Find(id)
                };

                //LoggerFactory.CreateLog().Debug(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - RemoveMedida Controller End"));
                return(View("MedidaRemoveView", model));
            }
            catch (Exception ex)
            {
                //LoggerFactory.CreateLog().Error(string.Format(CultureInfo.InvariantCulture, "Presentation Layer - RemoveMedida Controller ERROR"), ex);
            }

            return(RedirectToAction("Find"));
        }