Ejemplo n.º 1
0
        // GET: /RugStencilMaster/Create

        public ActionResult Create()
        {
            RugStencilViewModel vm = new RugStencilViewModel();

            PrepareViewBag(null);
            vm.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            return(View("Create", vm));
        }
Ejemplo n.º 2
0
        public ActionResult AddStencilSizePost(RugStencilViewModel vm)
        {
            if (ModelState.IsValid)
            {
                Product p = new Product();
                p.ProductCode  = vm.StencilName;
                p.ProductName  = vm.StencilName;
                p.IsActive     = true;
                p.CreatedBy    = User.Identity.Name;
                p.ModifiedBy   = User.Identity.Name;
                p.DivisionId   = vm.DivisionId;
                p.CreatedDate  = DateTime.Now;
                p.ModifiedDate = DateTime.Now;

                new ProductService(_unitOfWork).Create(p);

                RugStencil rs = new RugStencil();
                rs.FullHalf        = vm.FullHalf;
                rs.CreatedBy       = User.Identity.Name;
                rs.CreatedDate     = DateTime.Now;
                rs.ModifiedBy      = User.Identity.Name;
                rs.ModifiedDate    = DateTime.Now;
                rs.ProductDesignId = vm.ProductDesignId;
                rs.ProductSizeId   = vm.ProductSizeId;
                rs.StencilId       = p.ProductId;
                _RugStencilService.Create(rs);


                ProductSize ps = new ProductSize();

                ps.CreatedBy         = User.Identity.Name;
                ps.CreatedDate       = DateTime.Now;
                ps.IsActive          = true;
                ps.ModifiedBy        = User.Identity.Name;
                ps.ModifiedDate      = DateTime.Now;
                ps.ProductId         = p.ProductId;
                ps.ProductSizeTypeId = new ProductSizeTypeService(_unitOfWork).Find(SizeTypeConstants.Standard).ProductSizeTypeId;
                ps.SizeId            = vm.StencilSizeId;

                new ProductSizeService(_unitOfWork).Create(ps);

                try
                {
                    _unitOfWork.Save();
                }

                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    ModelState.AddModelError("", message);
                    return(PartialView("AddStencilSize", vm));
                }

                return(Json(new { success = true }));
            }
            return(PartialView("AddStencilSize", vm));
        }
Ejemplo n.º 3
0
        public ActionResult AddStencilSize(RugStencilViewModel vm)
        {
            RugStencilViewModel tvm = new RugStencilViewModel();

            tvm.FullHalf        = vm.FullHalf;
            tvm.DivisionId      = vm.DivisionId;
            tvm.ProductDesignId = vm.ProductDesignId;
            tvm.ProductSizeId   = vm.ProductSizeId;
            tvm.ProductSizeName = vm.ProductSizeName;
            tvm.StencilSizeId   = 0;
            tvm.StencilSizeName = "";
            //vm.ProductDesignName = new ProductDesignService(_unitOfWork).Find(vm.ProductDesignId).ProductDesignName;
            //vm = new RugStencilViewModel();
            return(PartialView("AddStencilSize", vm));
        }
Ejemplo n.º 4
0
        public void PrepareViewBag(RugStencilViewModel vm)
        {
            List <SelectListItem> temp = new List <SelectListItem>();

            temp.Add(new SelectListItem {
                Text = "Half", Value = "Half"
            });
            temp.Add(new SelectListItem {
                Text = "Full", Value = "Full"
            });

            if (vm == null)
            {
                ViewBag.HalfFull = new SelectList(temp, "Value", "Text");
            }
            else
            {
                ViewBag.HalfFull = new SelectList(temp, "Value", "Text", vm.FullHalf);
            }
        }