private static ReceivablePeriod getEntityByModel(ReceivablePeriodModel model)
        {
            if (model == null) return null;

            ReceivablePeriod entity = new ReceivablePeriod();

            if (model.Id == 0)
            {
                entity.CreateBy = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
                entity.CompanyId = AuthenticationHelper.CompanyId.Value;
            }
            else
            {
                entity.CreateBy = model.CreateBy;
                entity.CreateDate = model.CreateDate;
                entity.CompanyId = model.CompanyId;
            }

            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(ReceivablePeriod entity)
 {
     if (entity.IsValid())
         return this.repository.Update(entity);
     else
         return "Entity is not in valid state";
 }
 public string Update(ReceivablePeriod entity)
 {
     var originalEntity = this.Context.ReceivablePeriods.Find(entity.Id);
     this.Context.Entry(originalEntity).CurrentValues.SetValues(entity);
     this.Context.Entry(originalEntity).State = EntityState.Modified;
     this.Commit();
     return entity.Id.ToString();
 }
 public ReceivablePeriodModel(ReceivablePeriod entity)
 {
     if (entity != null)
     {
         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(ReceivablePeriod entity)
 {
     this.Context.ReceivablePeriods.Add(entity);
     this.Commit();
     return entity.Id.ToString();
 }