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 string Update(InventoryPeriod entity)
 {
     if (entity.IsValid())
         return this.repository.Update(entity);
     else
         return "Entity is not in valid state";
 }
 public string Update(InventoryPeriod entity)
 {
     var originalEntity = this.Context.InventoryPeriods.Find(entity.Id);
     this.Context.Entry(originalEntity).CurrentValues.SetValues(entity);
     this.Context.Entry(originalEntity).State = EntityState.Modified;
     this.Commit();
     return entity.Id.ToString();
 }
 public InventoryPeriodModel(InventoryPeriod entity)
 {
     this.Id = entity.Id;
     this.SOBId = entity.SOBId;
     this.Status = entity.Status;
     this.CalendarId = entity.CalendarId;
     this.CompanyId = entity.CompanyId;
     this.CreateBy = entity.CreateBy;
     this.CreateDate = entity.CreateDate;
     this.UpdateBy = entity.UpdateBy;
     this.UpdateDate = entity.UpdateDate;
 }
 public string Insert(InventoryPeriod entity)
 {
     this.Context.InventoryPeriods.Add(entity);
     this.Commit();
     return entity.Id.ToString();
 }