Ejemplo n.º 1
0
        public ActionResult ProductCategoryEdit(ProductCategoryView model, string saveclose, string savenew)
        {
            ProductCategoryView remodel = new ProductCategoryView();
            var actionStatus            = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            string message = "";
            bool   IsValid = true;

            if (ModelState.IsValid)
            {
                model.ModifiedBy = CurrentUser.ID;
                model.Language   = currentCulture.ToString();
                remodel          = _proCatRepo.Edit(model, out message);
                if (remodel != null && String.IsNullOrWhiteSpace(message))
                {
                    actionStatus.ErrorReason  = String.Format(SiteResource.HTML_ALERT_SUCCESS, Resources.MSG_THE_PRODUCT_CATEGORY_HAS_UPDATED_SUCCESSFULLLY);
                    actionStatus.ActionStatus = ResultSubmit.success;
                    Session["ACTION_STATUS"]  = actionStatus;
                    if (!String.IsNullOrEmpty(saveclose))
                    {
                        return(RedirectToAction("ProductCategory"));
                    }
                    else if (!String.IsNullOrWhiteSpace(savenew))
                    {
                        return(RedirectToAction("ProductCategoryCreate"));
                    }
                    else
                    {
                        return(RedirectToAction("ProductCategoryEdit", new { Id = remodel.ID }));
                    }
                }
                else
                {
                    IsValid = false;
                    actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_CATEGORY_HAS_UPDATED_UNSUCCESSFULLLY);
                    goto actionError;
                }
            }
actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason = String.Format(SiteResource.HTML_ALERT_ERROR, SiteResource.MSG_ERROR_ENTER_DATA_FOR_FORM + actionStatus.ShowErrorStrings());
                Session["ACTION_STATUS"] = actionStatus;
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult SetDeletedProduct(int Id = 0)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            string       message = "";
            bool         IsValid = true;
            ProductsView model   = _proRepo.GetProductById(Id, out message);

            if (model != null && Id > 0)
            {
                model.Status = nameof(StatusEntity.Deleted);
                model        = _proRepo.Edit(model, out message);
                if (model != null && String.IsNullOrWhiteSpace(message))
                {
                    actionStatus.ErrorReason  = String.Format(SiteResource.HTML_ALERT_SUCCESS, Resources.MSG_THE_PRODUCT_HAS_UPDATED_SUCCESSFULLLY);
                    actionStatus.ActionStatus = ResultSubmit.success;
                    Session["ACTION_STATUS"]  = actionStatus;
                    return(RedirectToAction("Products"));
                }
            }
            else
            {
                IsValid = false;
                actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_HAS_NOT_FOUND);
                goto actionError;
            }

actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason = String.Format(SiteResource.HTML_ALERT_ERROR, actionStatus.ShowErrorStrings());
                Session["ACTION_STATUS"] = actionStatus;
            }
            return(RedirectToAction("Products"));
        }
Ejemplo n.º 3
0
        public ActionResult ProductCategoryEdit(long Id = 0)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            bool IsValid = true;

            if (Id > 0)
            {
                string message            = null;
                ProductCategoryView model = _proCatRepo.GetProductCategoryById(Id, out message);
                if (model == null)
                {
                    IsValid = false;
                    actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_CATEGORY_HAS_NOT_FOUND);
                    goto actionError;
                }
                else
                {
                    ViewBag.Title = String.Format(Resources.LABEL_UPDATE, model.Name);
                    return(View(model));
                }
            }
            else
            {
                IsValid = false;
                actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_CATEGORY_HAS_NOT_FOUND);
                goto actionError;
            }
actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason = String.Format(SiteResource.HTML_ALERT_ERROR, actionStatus.ShowErrorStrings());
                Session["ACTION_STATUS"] = actionStatus;
            }
            return(RedirectToAction("ProductCategory"));
        }
Ejemplo n.º 4
0
        public ActionResult Edit(int id = 0)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            bool   IsValid = true;
            string message = String.Empty;

            if (id > 0)
            {
                var user = new UserDao().ViewDetail(id);
                if (user != null)
                {
                    return(View(user));
                }
                else
                {
                    IsValid = false;
                    actionStatus.ErrorStrings.Add(Resources.MSG_THE_USER_HAS_NOT_FOUND);
                    goto actionError;
                }
            }
            else
            {
                IsValid = false;
                actionStatus.ErrorStrings.Add(Resources.MSG_THE_USER_HAS_NOT_FOUND);
                goto actionError;
            }
actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason             = String.Format(SiteResource.HTML_ALERT_ERROR, actionStatus.ShowErrorStrings());
                Session[SessionName.ActionStatusLog] = actionStatus;
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public ActionResult ProductCreate(ProductsView model, string saveclose, string savenew)
        {
            ProductsView remodel      = new ProductsView();
            var          actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            string message = "";
            bool   IsValid = true;

            if (ModelState.IsValid)
            {
                model.ModifiedBy = CurrentUser.ID;
                model.Language   = currentCulture.ToString();
                model.CreatedBy  = CurrentUser.ID;
                remodel          = _proRepo.Create(model, out message);
                if (remodel != null && String.IsNullOrWhiteSpace(message))
                {
                    actionStatus.ErrorReason  = String.Format(SiteResource.HTML_ALERT_SUCCESS, Resources.MSG_THE_PRODUCT_HAS_CREATED_SUCCESSFULL);
                    actionStatus.ActionStatus = ResultSubmit.success;
                    Session["ACTION_STATUS"]  = actionStatus;

                    if (!String.IsNullOrEmpty(saveclose))
                    {
                        return(RedirectToAction("Products"));
                    }
                    else if (!String.IsNullOrWhiteSpace(savenew))
                    {
                        return(RedirectToAction("ProductCreate"));
                    }
                    else
                    {
                        return(RedirectToAction("ProductEdit", new { Id = remodel.ID }));
                    }
                }
                else
                {
                    IsValid = false;
                    actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_HAS_CREATED_SUCCESSFULL);
                    goto actionError;
                }
            }
actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason = String.Format(SiteResource.HTML_ALERT_ERROR, actionStatus.ShowErrorStrings());
                Session["ACTION_STATUS"] = actionStatus;
            }
            ViewBag.Title  = Resources.LABEL_CREATE_PRODUCT;
            ViewBag.Action = "ProductCreate";
            return(View("ProductEdit", model));
        }
Ejemplo n.º 6
0
        public ActionResult Create(ProductCategoryView model, string saveclose, string savenew)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            string message = "";
            bool   IsValid = true;

            if (ModelState.IsValid)
            {
                model.Language    = currentCulture.ToString();
                model.CreatedBy   = CurrentUser.UserID;
                model.ModifiedBy  = CurrentUser.UserID;
                model.CatalogueId = SiteConfiguration.CatalogueId;
                ProductCategoryView remodel = _proCatRepo.Create(model, out message);

                if (remodel != null && String.IsNullOrEmpty(message))
                {
                    actionStatus.ActionStatus            = ResultSubmit.success;
                    actionStatus.Message                 = String.Format(SiteResource.HTML_ALERT_SUCCESS, Resources.MSG_THE_PRODUCT_CATEGORY_HAS_CREATED_SUCCESSFULLLY);
                    Session[SessionName.ActionStatusLog] = actionStatus;

                    if (!String.IsNullOrEmpty(saveclose))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else if (!String.IsNullOrWhiteSpace(savenew))
                    {
                        return(RedirectToAction("Create"));
                    }
                    else
                    {
                        return(RedirectToAction("Edit", new { Id = remodel.ID }));
                    }
                }
                else
                {
                    actionStatus.ErrorReason             = String.Format(SiteResource.HTML_ALERT_ERROR, Resources.MSG_THE_PRODUCT_CATEGORY_HAS_CREATED_UNSUCCESSFULLLY);
                    Session[SessionName.ActionStatusLog] = actionStatus;
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                IsValid = false;
                goto actionError;
            }

actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason             = String.Format(SiteResource.HTML_ALERT_ERROR, Resources.MSG_ERROR_ENTER_DATA_FOR_FORM + actionStatus.ShowErrorStrings());
                Session[SessionName.ActionStatusLog] = actionStatus;
            }

            ViewBag.Title  = Resources.MSG_THE_PRODUCT_CATEGORY_HAS_CREATED_UNSUCCESSFULLLY;
            ViewBag.Action = "Create";
            return(View("Edit", model));
        }
Ejemplo n.º 7
0
        public ActionResult Edit(ProductCategoryView model, string saveclose, string savenew)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            string message = String.Empty;
            bool   IsValid = true;

            // TODO: Add update logic here
            if (ModelState.IsValid)
            {
                model.Language    = currentCulture.ToString();
                model.ModifiedBy  = CurrentUser.UserID;
                model.CatalogueId = SiteConfiguration.CatalogueId;
                var result = _proCatRepo.Edit(model, out message);
                var dao    = new ProductCategoryDao();
                Mapper.Initialize(cfg => cfg.CreateMap <ProductCategoryView, ProductCategory>());
                var data = Mapper.Map <ProductCategoryView, ProductCategory>(model);
                if (result != null && String.IsNullOrEmpty(message))
                {
                    actionStatus.ActionStatus            = ResultSubmit.success;
                    actionStatus.Message                 = String.Format(SiteResource.HTML_ALERT_SUCCESS, Resources.MSG_THE_PRODUCT_CATEGORY_HAS_UPDATED_SUCCESSFULLLY);
                    Session[SessionName.ActionStatusLog] = actionStatus;
                    if (!String.IsNullOrEmpty(saveclose))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else if (!String.IsNullOrWhiteSpace(savenew))
                    {
                        return(RedirectToAction("Create"));
                    }
                    else
                    {
                        return(RedirectToAction("Edit", new { Id = model.ID }));
                    }
                }
                else
                {
                    actionStatus.ErrorReason             = String.Format(SiteResource.HTML_ALERT_ERROR, Resources.MSG_THE_PRODUCT_CATEGORY_HAS_UPDATED_UNSUCCESSFULLLY);
                    Session[SessionName.ActionStatusLog] = actionStatus;
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                IsValid = false;
                goto actionError;
            }

actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason             = String.Format(SiteResource.HTML_ALERT_ERROR, Resources.MSG_ERROR_ENTER_DATA_FOR_FORM + actionStatus.ShowErrorStrings());
                Session[SessionName.ActionStatusLog] = actionStatus;
            }

            return(View(model));
        }
Ejemplo n.º 8
0
        public ActionResult Edit(long id = 0)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            bool IsValid = true;
            var  dao     = new ProductCategoryDao();
            ProductCategoryView model = new ProductCategoryView();

            if (id > 0)
            {
                model = dao.Find(id);
                if (model == null)
                {
                    IsValid = false;
                    actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_CATEGORY_HAS_NOT_FOUND);
                    goto actionError;
                }
                else
                {
                    ViewBag.Title = String.Format(Resources.LABEL_UPDATE, model.Name);
                    return(View(model));
                }
            }
            else
            {
                IsValid = false;
                actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_CATEGORY_HAS_NOT_FOUND);
                goto actionError;
            }
actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason             = String.Format(SiteResource.HTML_ALERT_ERROR, actionStatus.ShowErrorStrings());
                Session[SessionName.ActionStatusLog] = actionStatus;
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
        public ActionResult DeleteProductDetail(long ProductId = 0, long productDetailId = 0)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            bool IsValid = true;

            if (ProductId > 0 && productDetailId > 0)
            {
                DAO.DeleteProductDeteail(productDetailId);
                actionStatus.ActionStatus = ResultSubmit.success;
                actionStatus.Message      = String.Format(SiteResource.HTML_ALERT_SUCCESS, SiteResource.MSG_THE_PRODUCT_WEIGHT_PRICE_HAS_BEEN_REMOVED);
                return(RedirectToAction("Edit", new { id = ProductId }));
            }
            else
            {
                IsValid = false;
                actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_HAS_NOT_FOUND);
                goto actionError;
            }
actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason             = String.Format(SiteResource.HTML_ALERT_ERROR, actionStatus.ShowErrorStrings());
                Session[SessionName.ActionStatusLog] = actionStatus;
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 10
0
        public ActionResult CreateProductDetail(long ProductId = 0)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            bool IsValid = true;

            if (ProductId > 0)
            {
                DAO.CreateGetProductDetail(ProductId);
                return(RedirectToAction("Edit", new { id = ProductId }));
            }
            else
            {
                IsValid = false;
                actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_HAS_NOT_FOUND);
                goto actionError;
            }
actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason             = String.Format(SiteResource.HTML_ALERT_ERROR, actionStatus.ShowErrorStrings());
                Session[SessionName.ActionStatusLog] = actionStatus;
            }
            return(RedirectToAction("Index"));
        }