public ActionResult _Edit(int id)
        {
            var ProdProcess = new ProductProcessService(_unitOfWork).Find(id);

            if (ProdProcess.ProcessId != null)
            {
                var Process = new ProcessService(_unitOfWork).Find((int)ProdProcess.ProcessId);
                ViewBag.ProcessName = Process.ProcessName;
            }
            else
            {
                ViewBag.ProcessName = "";
            }



            ProductProcessViewModel vm = new ProductProcessViewModel();

            vm.Instructions       = ProdProcess.Instructions;
            vm.ProcessId          = ProdProcess.ProcessId;
            vm.ProductId          = ProdProcess.ProductId;
            vm.ProductProcessId   = ProdProcess.ProductProcessId;
            vm.ProductRateGroupId = ProdProcess.ProductRateGroupId;
            vm.QAGroupId          = ProdProcess.QAGroupId;
            vm.Sr = ProdProcess.Sr;

            return(PartialView("_Create", vm));
        }
        public ActionResult _Create(int Id) //Id ==>Product Id
        {
            int ProductTypeId = (from p in db.Product
                                 where p.ProductId == Id
                                 select new
            {
                ProductTypeId = p.ProductGroup.ProductTypeId
            }).FirstOrDefault().ProductTypeId;

            ProductProcessViewModel s = new ProductProcessViewModel();

            s.ProductId = Id;
            PrepareViewBag(s);
            return(PartialView("_Create", s));
        }
        public ActionResult DeletePost(ProductProcessViewModel vm)
        {
            ProductProcess ProductProcess = _ProductProcessService.Find(vm.ProductProcessId);

            _ProductProcessService.Delete(vm.ProductProcessId);

            try
            {
                _unitOfWork.Save();
            }

            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                ModelState.AddModelError("", message);
                return(PartialView("EditSize", vm));
            }
            return(Json(new { success = true }));
        }
        public ActionResult _CreatePost(ProductProcessViewModel svm)
        {
            if (ModelState.IsValid)
            {
                if (svm.ProductProcessId == 0)
                {
                    ProductProcess ProductProcess = new ProductProcess();

                    ProductProcess.ProductId          = svm.ProductId;
                    ProductProcess.ProcessId          = svm.ProcessId;
                    ProductProcess.Dimension1Id       = svm.Dimension1Id;
                    ProductProcess.Dimension2Id       = svm.Dimension2Id;
                    ProductProcess.Dimension3Id       = svm.Dimension3Id;
                    ProductProcess.Dimension4Id       = svm.Dimension4Id;
                    ProductProcess.QAGroupId          = svm.QAGroupId;
                    ProductProcess.ProductRateGroupId = svm.ProductRateGroupId;
                    ProductProcess.Instructions       = svm.Instructions;

                    ProductProcess.CreatedDate  = DateTime.Now;
                    ProductProcess.ModifiedDate = DateTime.Now;
                    ProductProcess.CreatedBy    = User.Identity.Name;
                    ProductProcess.ModifiedBy   = User.Identity.Name;
                    ProductProcess.ObjectState  = Model.ObjectState.Added;
                    _ProductProcessService.Create(ProductProcess);


                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }
                    return(RedirectToAction("_Create", new { id = svm.ProductId }));
                }
                else
                {
                    ProductProcess ProductProcess = _ProductProcessService.Find(svm.ProductProcessId);
                    StringBuilder  logstring      = new StringBuilder();

                    ProductProcess.ProductId          = svm.ProductId;
                    ProductProcess.ProductId          = svm.ProductId;
                    ProductProcess.ProcessId          = svm.ProcessId;
                    ProductProcess.Dimension1Id       = svm.Dimension1Id;
                    ProductProcess.Dimension2Id       = svm.Dimension2Id;
                    ProductProcess.Dimension3Id       = svm.Dimension3Id;
                    ProductProcess.Dimension4Id       = svm.Dimension4Id;
                    ProductProcess.QAGroupId          = svm.QAGroupId;
                    ProductProcess.ProductRateGroupId = svm.ProductRateGroupId;
                    ProductProcess.Instructions       = svm.Instructions;


                    ProductProcess.ModifiedDate = DateTime.Now;
                    ProductProcess.ModifiedBy   = User.Identity.Name;
                    ProductProcess.ObjectState  = Model.ObjectState.Modified;
                    _ProductProcessService.Update(ProductProcess);


                    //Saving the Activity Log
                    ActivityLog al = new ActivityLog()
                    {
                        ActivityType = (int)ActivityTypeContants.Modified,
                        DocId        = ProductProcess.ProductProcessId,
                        CreatedDate  = DateTime.Now,
                        Narration    = logstring.ToString(),
                        CreatedBy    = User.Identity.Name,
                        //DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(TransactionDocCategoryConstants.ProductProcess).DocumentTypeId,
                    };
                    new ActivityLogService(_unitOfWork).Create(al);
                    //End of Saving the Activity Log


                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }
                    return(Json(new { success = true }));
                }
            }

            PrepareViewBag(svm);
            return(PartialView("_Create", svm));
        }
 private void PrepareViewBag(ProductProcessViewModel svm)
 {
 }