Ejemplo n.º 1
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.º 2
0
        // GET: /ProductMaster/Edit/5

        public ActionResult Edit(int id)
        {
            RugStencil pt = _RugStencilService.Find(id);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            return(View("Create", pt));
        }
Ejemplo n.º 3
0
        // POST: /ProductMaster/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit(RugStencil pt)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        RugStencil temp = _RugStencilService.Find(pt.RugStencilId);
        //        temp.RugStencilName = pt.RugStencilName;
        //        temp.IsActive = pt.IsActive;
        //        temp.ModifiedDate = DateTime.Now;
        //        temp.ModifiedBy = User.Identity.Name;
        //        temp.ObjectState = Model.ObjectState.Modified;
        //        _RugStencilService.Update(temp);

        //        try
        //        {
        //            _unitOfWork.Save();
        //        }
        //        catch (DbEntityValidationException dbex)
        //        {
        //            string message = _exception.HandleEntityValidationException(dbex);
        //            ModelState.AddModelError("", message);
        //            return View("Create", pt);
        //        }
        //        catch (DbUpdateException du)
        //        {
        //            string message = _exception.HandleUpdateException(du);
        //            ModelState.AddModelError("", message);
        //            return View("Create", pt);
        //        }
        //        catch (Exception ex)
        //        {
        //            string message = _exception.HandleException(ex);
        //            ModelState.AddModelError("", message);
        //            return View("Create", pt);

        //        }


        //        return RedirectToAction("Index").Success("Data saved successfully");
        //    }
        //    return View("Create", pt);
        //}

        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RugStencil RugStencil = db.RugStencil.Find(id);

            if (RugStencil == null)
            {
                return(HttpNotFound());
            }
            ReasonViewModel vm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", vm));
        }
Ejemplo n.º 4
0
 public void Update(RugStencil pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository<RugStencil>().Update(pt);
 }
Ejemplo n.º 5
0
 public void Delete(RugStencil pt)
 {
     _unitOfWork.Repository<RugStencil>().Delete(pt);
 }
Ejemplo n.º 6
0
 public RugStencil Create(RugStencil pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository<RugStencil>().Insert(pt);
     return pt;
 }
Ejemplo n.º 7
0
 public RugStencil Add(RugStencil pt)
 {
     _unitOfWork.Repository<RugStencil>().Insert(pt);
     return pt;
 }