Example #1
0
        public ActionResult Detail(int id, string returl, string transactionType)
        {
            ProcessSequenceHeaderIndexViewModel        h      = (ProcessSequenceHeaderIndexViewModel)_ProcessSequenceHeaderService.GetProcessSequenceHeaderVM(id);
            ProcessSequenceHeaderIndexViewModelForEdit Header = Mapper.Map <ProcessSequenceHeaderIndexViewModel, ProcessSequenceHeaderIndexViewModelForEdit>(h);

            List <ProcessSequenceLineIndexViewModel> l = new ProcessSequenceLineService(_unitOfWork).GetProcessSequenceLineList(id).ToList();

            ProcessSequenceMasterDetailModel vm = new ProcessSequenceMasterDetailModel();

            vm.ProcessSequenceHeaderIndexViewModelForEdit = Header;
            vm.ProcessSequenceLineIndexViewModel          = l;


            ViewBag.transactionType    = transactionType;
            vm.ProcessSequenceHeaderId = vm.ProcessSequenceHeaderIndexViewModelForEdit.ProcessSequenceHeaderId;

            if (String.IsNullOrEmpty(transactionType) || transactionType == "detail")
            {
                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocId        = h.ProcessSequenceHeaderId,
                    DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                    ActivityType = (int)ActivityTypeContants.Detail,
                    DocNo        = h.ProcessSequenceHeaderName.Substring(0, 20),
                }));
            }

            return(View(vm));
        }
Example #2
0
        // GET: /ProcessSequenceHeader/Edit/5
        public ActionResult Edit(int id, string PrevAction, string PrevController)
        {
            if (PrevAction != null)
            {
                ViewBag.Redirect = PrevAction;
            }

            ProcessSequenceHeader s = _ProcessSequenceHeaderService.GetProcessSequenceHeader(id);
            ProcessSequenceHeaderIndexViewModel svm = Mapper.Map <ProcessSequenceHeader, ProcessSequenceHeaderIndexViewModel>(s);

            PrepareViewBag(svm);
            if (s == null)
            {
                return(HttpNotFound());
            }

            if (!(System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery).Contains("Create"))
            {
                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocId        = s.ProcessSequenceHeaderId,
                    DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                    ActivityType = (int)ActivityTypeContants.Detail,
                    DocNo        = s.ProcessSequenceHeaderName.Length > 20 ?s.ProcessSequenceHeaderName.Substring(0, 20) : s.ProcessSequenceHeaderName,
                    DocStatus    = s.Status,
                }));
            }

            return(View("Create", svm));
        }
Example #3
0
        public ProcessSequenceHeaderIndexViewModel GetProcessSequenceHeaderVM(int id)
        {
            ProcessSequenceHeaderIndexViewModel temp = (from p in db.ProcessSequenceHeader
                                                        where p.ProcessSequenceHeaderId == id
                                                        select new ProcessSequenceHeaderIndexViewModel
            {
                ProcessSequenceHeaderId = p.ProcessSequenceHeaderId,
                ProcessSequenceHeaderName = p.ProcessSequenceHeaderName,
                CreatedBy = p.CreatedBy,
                CreatedDate = p.CreatedDate,
            }

                                                        ).FirstOrDefault();

            return(temp);
        }
Example #4
0
        // GET: /PurchaseOrderHeader/Delete/5

        public ActionResult Delete(int id, string PrevAction, string PrevController)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProcessSequenceHeaderIndexViewModel ProcessSequenceHeader = _ProcessSequenceHeaderService.GetProcessSequenceHeaderVM(id);

            if (ProcessSequenceHeader == null)
            {
                return(HttpNotFound());
            }
            ReasonViewModel rvm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", rvm));
        }
Example #5
0
        public ActionResult HeaderPost(ProcessSequenceHeaderIndexViewModel svm)
        {
            if (ModelState.IsValid)
            {
                if (svm.ProcessSequenceHeaderId == 0)
                {
                    ProcessSequenceHeader s = Mapper.Map <ProcessSequenceHeaderIndexViewModel, ProcessSequenceHeader>(svm);
                    s.CreatedDate  = DateTime.Now;
                    s.ModifiedDate = DateTime.Now;
                    s.CreatedBy    = User.Identity.Name;
                    s.ModifiedBy   = User.Identity.Name;
                    _ProcessSequenceHeaderService.Create(s);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                        DocId        = s.ProcessSequenceHeaderId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("Edit", new { id = s.ProcessSequenceHeaderId }).Success("Data saved Successfully"));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    ProcessSequenceHeader s    = Mapper.Map <ProcessSequenceHeaderIndexViewModel, ProcessSequenceHeader>(svm);
                    ProcessSequenceHeader temp = _ProcessSequenceHeaderService.Find(s.ProcessSequenceHeaderId);

                    ProcessSequenceHeader ExRec = Mapper.Map <ProcessSequenceHeader>(temp);

                    temp.ProcessSequenceHeaderName = s.ProcessSequenceHeaderName;
                    temp.ModifiedDate = DateTime.Now;
                    temp.ModifiedBy   = User.Identity.Name;
                    _ProcessSequenceHeaderService.Update(temp);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });

                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                        DocId           = temp.ProcessSequenceHeaderId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            PrepareViewBag(svm);
            return(View("Create", svm));
        }
Example #6
0
        // GET: /ProcessSequenceHeader/Create

        public ActionResult Create()
        {
            ProcessSequenceHeaderIndexViewModel p = new ProcessSequenceHeaderIndexViewModel();

            return(View("Create", p));
        }
Example #7
0
 private void PrepareViewBag(ProcessSequenceHeaderIndexViewModel s)
 {
 }