예제 #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));
        }
예제 #2
0
        public ActionResult Delete(ReasonViewModel vm)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            if (ModelState.IsValid)
            {
                //string temp = (Request["Redirect"].ToString());
                //first find the Purchase Order Object based on the ID. (sience this object need to marked to be deleted IE. ObjectState.Deleted)
                var ProcessSequenceHeader = _ProcessSequenceHeaderService.GetProcessSequenceHeader(vm.id);

                LogList.Add(new LogTypeViewModel
                {
                    ExObj = ProcessSequenceHeader,
                });

                //Then find all the Purchase Order Header Line associated with the above ProductType.
                var ProcessSequenceLine = new ProcessSequenceLineService(_unitOfWork).GetProcessSequenceLineList(vm.id);

                //Mark ObjectState.Delete to all the Purchase Order Lines.
                foreach (var item in ProcessSequenceLine)
                {
                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = item,
                    });
                    new ProcessSequenceLineService(_unitOfWork).Delete(item.ProcessSequenceLineId);
                }

                // Now delete the Purhcase Order Header
                new ProcessSequenceHeaderService(_unitOfWork).Delete(vm.id);
                XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);
                //Commit the DB
                try
                {
                    _unitOfWork.Save();
                }

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

                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProcessSequence).DocumentTypeId,
                    DocId           = vm.id,
                    ActivityType    = (int)ActivityTypeContants.Deleted,
                    UserRemark      = vm.Reason,
                    xEModifications = Modifications,
                }));

                return(Json(new { success = true }));
            }
            return(PartialView("_Reason", vm));
        }