public string DataValidation(CustomDetailViewModel svm)
        {
            string ValidationMsg = "";


            return(ValidationMsg);
        }
        public ActionResult Detail(int id, string returl, string transactionType)
        {
            CustomDetailViewModel        H      = _CustomDetailService.GetCustomDetailViewModel(id);
            CustomDetailViewModelWithLog Header = Mapper.Map <CustomDetailViewModel, CustomDetailViewModelWithLog>(H);

            ViewBag.transactionType = transactionType;
            return(View(Header));
        }
        // GET: /CustomDetail/Create

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

            p.DocDate    = DateTime.Now.Date;
            p.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            p.SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
            p.DocNo      = _CustomDetailService.GetMaxDocNo();
            PrepareViewBag(p);
            return(View(p));
        }
        public ActionResult Edit(int id, string PrevAction, string PrevController)
        {
            if (PrevAction != null)
            {
                ViewBag.Redirect = PrevAction;
            }

            CustomDetail          s   = _CustomDetailService.Find(id);
            CustomDetailViewModel svm = new CustomDetailViewModel();

            svm = Mapper.Map <CustomDetail, CustomDetailViewModel>(s);

            PrepareViewBag(svm);
            if (svm == null)
            {
                return(HttpNotFound());
            }
            return(View("Create", svm));
        }
예제 #5
0
        public CustomDetailViewModel GetCustomDetailViewModel(int id)
        {
            CustomDetailViewModel packingheaderlistpendingtoapprove = (from H in db.CustomDetail
                                                                       join s in db.SaleInvoiceHeader on H.SaleInvoiceHeaderId equals s.SaleInvoiceHeaderId into SaleInvoiceHeaderTable
                                                                       from SaleInvoiceHeaderTab in SaleInvoiceHeaderTable.DefaultIfEmpty()
                                                                       orderby H.DocDate descending, H.DocNo descending
                                                                       where H.CustomDetailId == id
                                                                       select new CustomDetailViewModel
            {
                CustomDetailId = H.CustomDetailId,
                DocDate = H.DocDate,
                DocNo = H.DocNo,
                SaleInvoiceHeaderDocNo = SaleInvoiceHeaderTab.DocNo,
                TRNo = H.TRNo,
                TRDate = H.TRDate,
                Remark = H.Remark,
            }).FirstOrDefault();

            return(packingheaderlistpendingtoapprove);
        }
        public ActionResult Create(CustomDetailViewModel svm)
        {
            string DataValidationMsg = DataValidation(svm);

            if (DataValidationMsg != "")
            {
                PrepareViewBag(svm);
                return(View(svm).Danger(DataValidationMsg));
            }

            if (ModelState.IsValid)
            {
                if (svm.CustomDetailId == 0)
                {
                    CustomDetail CustomDetail = Mapper.Map <CustomDetailViewModel, CustomDetail>(svm);
                    CustomDetail.CreatedDate  = DateTime.Now;
                    CustomDetail.ModifiedDate = DateTime.Now;
                    CustomDetail.CreatedBy    = User.Identity.Name;
                    CustomDetail.ModifiedBy   = User.Identity.Name;
                    CustomDetail.Status       = (int)StatusConstants.Drafted;
                    _CustomDetailService.Create(CustomDetail);

                    try
                    {
                        _unitOfWork.Save();
                    }

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

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

                    return(RedirectToAction("Edit", new { id = CustomDetail.CustomDetailId }).Success("Data saved Successfully"));
                }

                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    CustomDetail CustomDetail = Mapper.Map <CustomDetailViewModel, CustomDetail>(svm);

                    CustomDetail ExRec = Mapper.Map <CustomDetail>(CustomDetail);

                    int status = CustomDetail.Status;

                    if (CustomDetail.Status == (int)StatusConstants.Approved)
                    {
                        CustomDetail.Status = (int)StatusConstants.Modified;
                    }

                    CustomDetail.Status       = (int)StatusConstants.Modified;
                    CustomDetail.ModifiedDate = DateTime.Now;
                    CustomDetail.ModifiedBy   = User.Identity.Name;
                    _CustomDetailService.Update(CustomDetail);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = CustomDetail,
                    });
                    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.CustomDetail).DocumentTypeId,
                        DocId           = CustomDetail.CustomDetailId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            PrepareViewBag(svm);
            return(View("Create", svm));
        }
 private void PrepareViewBag(CustomDetailViewModel s)
 {
     ViewBag.DocTypeList = new DocumentTypeService(_unitOfWork).GetDocumentTypeList(TransactionDocCategoryConstants.CustomDetail);
 }