private static InventoryPeriod getEntityByModel(InventoryPeriodModel model)
        {
            if (model == null)
                return null;

            InventoryPeriod entity = new InventoryPeriod();
            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;
        }
 public static string Save(InventoryPeriodModel model)
 {
     if (model.Id > 0)
     {
         return service.Update(getEntityByModel(model));
     }
     else
     {
         return service.Insert(getEntityByModel(model));
     }
 }
 public ActionResult DeleteInline(InventoryPeriodModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             model.CompanyId = AuthenticationHelper.CompanyId.Value;
             InventoryPeriodHelper.Delete(model.Id.ToString());
             return PartialView("_List", InventoryPeriodHelper.GetInventoryPeriods(SessionHelper.SOBId));
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
         ViewData["EditError"] = "Please, correct all errors.";
     return PartialView("_List", InventoryPeriodHelper.GetInventoryPeriods(SessionHelper.SOBId));
 }