コード例 #1
0
        public JsonResult Save(UserSetofBookModel model)
        {
            UserSetofBookModel defaultSOB = UserSetofBookHelper.GetDefaultSOB();

            if (defaultSOB != null)
            {
                model.Id = defaultSOB.Id;
            }

            //Remove all transaction's session that depends on SOB..
            SessionHelper.JV                       = null;
            SessionHelper.Invoice                  = null;
            SessionHelper.PayableInvoice           = null;
            SessionHelper.Payment                  = null;
            SessionHelper.Order                    = null;
            SessionHelper.MiscellaneousTransaction = null;
            SessionHelper.Locator                  = null;
            SessionHelper.Receipts                 = null;
            SessionHelper.Bank                     = null;
            SessionHelper.BankAccount              = null;
            SessionHelper.Calendar                 = null;
            SessionHelper.Item                     = null;
            SessionHelper.Remittance               = null;
            SessionHelper.Tax                      = null;
            SessionHelper.Shipment                 = null;

            model.UserId    = AuthenticationHelper.UserId;
            model.CompanyId = AuthenticationHelper.CompanyId.Value;

            SessionHelper.SOBId   = model.SOBId;
            SessionHelper.SOBName = SetOfBookHelper.GetSetOfBook(SessionHelper.SOBId.ToString()).Name;

            return(Json(UserSetofBookHelper.Save(model)));
        }
コード例 #2
0
        public ActionResult Index()
        {
            if (TempData["LastURL"] == null)
            {
                TempData["LastURL"] = Request.UrlReferrer.AbsolutePath;
            }

            UserSetofBookModel model = new UserSetofBookModel();

            //if(SessionHelper.SOBId != null && SessionHelper.SOBId != 0)
            if (SessionHelper.SOBId != 0)
            {
                model = UserSetofBookHelper.GetDefaultSOB();
                if (model != null)
                {
                    model.SetofBooks = SetOfBookHelper.GetSetOfBookList();
                    return(PartialView("_Create", model));
                }
            }
            model = new UserSetofBookModel
            {
                SetofBooks = SetOfBookHelper.GetSetOfBookList(),
                CompanyId  = AuthenticationHelper.CompanyId.Value,
                SOBId      = SessionHelper.SOBId,
                UserId     = AuthenticationHelper.UserId
            };

            return(PartialView("_Create", model));
        }
コード例 #3
0
 public static string Save(UserSetofBookModel model)
 {
     if (model.Id > 0)
     {
         return(service.Update(getEntityByModel(model)));
     }
     else
     {
         return(service.Insert(getEntityByModel(model)));
     }
 }
コード例 #4
0
        private static UserSetofBook getEntityByModel(UserSetofBookModel model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new UserSetofBook
            {
                CompanyId = model.CompanyId,
                Id = model.Id,
                UserId = model.UserId,
                SOBId = model.SOBId,
            });
        }