Esempio n. 1
0
        private PurchasingPeriod getEntityByModel(PurchasingPeriodModel model)
        {
            if (model == null)
            {
                return(null);
            }

            PurchasingPeriod entity = new PurchasingPeriod();

            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.CalendarId = model.CalendarId;
            entity.Id         = model.Id;
            entity.SOBId      = model.SOBId;
            entity.Status     = model.Status;
            entity.UpdateBy   = AuthenticationHelper.UserId;
            entity.UpdateDate = DateTime.Now;
            return(entity);
        }
Esempio n. 2
0
 private string Save(PurchasingPeriodModel model)
 {
     if (model.Id > 0)
     {
         return(service.Update(getEntityByModel(model)));
     }
     else
     {
         return(service.Insert(getEntityByModel(model)));
     }
 }
Esempio n. 3
0
 public ActionResult UpdateInline(PurchasingPeriodModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             model.CompanyId = AuthenticationHelper.CompanyId.Value;
             model.SOBId     = SessionHelper.SOBId;
             Save(model);
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_List", service.GetAll(AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId)
                        .Select(x => new PurchasingPeriodModel(x)).ToList()));
 }