예제 #1
0
        public ActionResult Outlet(OutletModel outletModel, string submitButton)
        {
            int result = 0;

            outletModel.StoreList = _iDropDownService.GetStoreList();

            if (!ModelState.IsValid)
            {
                string errorString = this.ValidationOutlet(outletModel);
                if (!string.IsNullOrEmpty(errorString))
                {
                    ViewBag.Validate = errorString;
                    return(View(outletModel));
                }
            }

            if (outletModel.Id > 0)
            {
                result = _iOutletService.UpdateOutlet(outletModel);
                if (result == -1)
                {
                    ViewBag.Result      = _locService.GetLocalizedHtmlString("Store is already allocated to other outlet!");
                    ViewBag.UpdateError = _locService.GetLocalizedHtmlString("UpdateError");
                    return(View(outletModel));
                }
                else
                {
                    ViewBag.Result = _locService.GetLocalizedHtmlString("EditSuccss");
                }
            }
            else
            {
                result = _iOutletService.InsertOutlet(outletModel);
                if (result == -1)
                {
                    ViewBag.Result    = _locService.GetLocalizedHtmlString("Store is already allocated to other outlet!");
                    ViewBag.SaveError = _locService.GetLocalizedHtmlString("SaveError");
                    return(View(outletModel));
                }
                else
                {
                    ViewBag.Result = _locService.GetLocalizedHtmlString("SaveSuccess");
                }
            }
            return(RedirectToAction("Index", "Outlet"));
        }