コード例 #1
0
        public static InvoiceSourceViewModel GetInvoiceSource(string id)
        {
            InvoiceSourceViewModel invoiceSource = new InvoiceSourceViewModel
                                                       (service.GetSingle(id, AuthenticationHelper.CompanyId.Value));

            return(invoiceSource);
        }
コード例 #2
0
        private static InvoiceSource getEntityByModel(InvoiceSourceViewModel model)
        {
            if (model == null)
            {
                return(null);
            }
            InvoiceSource entity = new InvoiceSource();

            entity.CodeCombinationId = model.CodeCombinationId;
            entity.StartDate         = model.StartDate;
            entity.EndDate           = model.EndDate;
            entity.Description       = model.Description;
            entity.Id    = model.Id;
            entity.SOBId = model.SOBId;
            if (model.Id == 0)
            {
                entity.CompanyId  = AuthenticationHelper.CompanyId.Value;
                entity.CreateBy   = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
            }
            else
            {
                entity.CompanyId  = model.CompanyId;
                entity.CreateBy   = model.CreateBy;
                entity.CreateDate = model.CreateDate;
            }
            entity.UpdateDate = DateTime.Now;
            entity.UpdateBy   = AuthenticationHelper.UserId;

            return(entity);
        }
コード例 #3
0
        public ActionResult Create()
        {
            InvoiceSourceViewModel model = new InvoiceSourceViewModel();

            model.SOBId            = SessionHelper.SOBId;
            model.CodeCombinations = CodeCombinationHelper.GetAccounts(SessionHelper.SOBId, model.StartDate, model.EndDate);
            return(View("Edit", model));
        }
コード例 #4
0
        public ActionResult Edit(string id)
        {
            InvoiceSourceViewModel model = InvoiceSourceHelper.GetInvoiceSource(id);

            CodeCombinitionCreateViewModel codeCombination = CodeCombinationHelper.GetCodeCombination(model.CodeCombinationId.ToString());

            model.CodeCombinationIdString = Utility.Stringize(".", codeCombination.Segment1, codeCombination.Segment2, codeCombination.Segment3,
                                                              codeCombination.Segment4, codeCombination.Segment5, codeCombination.Segment6, codeCombination.Segment7, codeCombination.Segment8);

            return(View(model));
        }
コード例 #5
0
 public static string SaveInvoiceSource(InvoiceSourceViewModel model)
 {
     if (model.Id > 0)
     {
         return(service.Update(getEntityByModel(model)));
     }
     else
     {
         return(service.Insert(getEntityByModel(model)));
     }
 }
コード例 #6
0
 public ActionResult Edit(InvoiceSourceViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             string result = InvoiceSourceHelper.SaveInvoiceSource(model);
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("error", ex.Message);
         }
     }
     return(View(model));
 }