Пример #1
0
        public ActionResult SaveProduct(Product model)
        {
            try
            {
                if (model.ImageFile != null)
                {
                    model.Image = Util.GetBase64FromImage(model.ImageFile);
                }
                model.ImageFile = null;

                if (model.Oid == Guid.Empty)
                {
                    model.State = Entities.Enums.ItemState.Active;
                    var res = ApiUtil.AddProduct(model).Result;
                }
                else
                {
                    var res = ApiUtil.UpdateProduct(model).Result;
                }
                return(RedirectToAction("ListProduct"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", new RouteValueDictionary(new { controller = "ErrorHandler", action = "Index", data = ex.InnerException?.Message ?? ex.Message })));
            }
        }