Example #1
0
        public ActionResult IngredientUnit(IngredientUnitModel ingredientUniModel, string submitButton)
        {
            if (!ModelState.IsValid)
            {
                string errorString = this.ValidationIngredientUnit(ingredientUniModel);
                if (!string.IsNullOrEmpty(errorString))
                {
                    ViewBag.Validate = errorString;
                    return(View(ingredientUniModel));
                }
            }

            if (ingredientUniModel.Id > 0)
            {
                var result = _iIngredientUnitService.UpdateIngredientUnit(ingredientUniModel);
                if (result == -1)
                {
                    ModelState.AddModelError("IngredientUnitName", "Unit name already exists");
                    return(View(ingredientUniModel));
                }
                ViewBag.Result = _locService.GetLocalizedHtmlString("EditSuccss");
            }
            else
            {
                var result = _iIngredientUnitService.InsertIngredientUnit(ingredientUniModel);
                if (result == -1)
                {
                    ModelState.AddModelError("IngredientUnitName", "Unit name already exists");
                    return(View(ingredientUniModel));
                }
                ViewBag.Result = _locService.GetLocalizedHtmlString("SaveSuccess");
            }

            return(RedirectToAction("Index", "IngredientUnit"));
        }
Example #2
0
        public ActionResult AddUnit(IngredientUnitModel ingredientUniModel)
        {
            var result = _iIngredientUnitService.InsertIngredientUnit(ingredientUniModel);

            if (result == -1)
            {
                return(Json(new { result = -1 }));
            }
            return(Json(new { result = true }));
        }