private static Calendar getEntityByModel(CalendarViewModel model)
        {
            if (model == null) return null;

            Calendar entity = new Calendar();

            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.Adjusting = model.Adjusting;
            entity.ClosingStatus = model.ClosingStatus;
            entity.EndDate = model.EndDate;
            entity.Id = model.Id;
            entity.PeriodName = model.PeriodName;
            entity.PeriodQuarter = model.PeriodQuarter;
            entity.PeriodYear = model.PeriodYear;
            entity.SeqNumber = model.SeqNumber;
            entity.SOBId = model.SOBId;
            entity.StartDate = model.StartDate;
            entity.UpdateDate = DateTime.Now;
            entity.UpdateBy = AuthenticationHelper.UserId;
            return entity;
        }
 public string Update(Calendar entity)
 {
     var originalEntity = this.Context.Calendars.Find(entity.Id);
     this.Context.Entry(originalEntity).CurrentValues.SetValues(entity);
     this.Context.Entry(originalEntity).State = EntityState.Modified;
     this.Commit();
     return entity.Id.ToString();
 }
 public CalendarViewModel(Calendar entity)
 {
     this.Adjusting = entity.Adjusting;
     this.ClosingStatus = entity.ClosingStatus;
     this.EndDate = entity.EndDate;
     this.Id = entity.Id;
     this.PeriodName = entity.PeriodName;
     this.PeriodQuarter = entity.PeriodQuarter;
     this.PeriodYear = entity.PeriodYear;
     this.SeqNumber = entity.SeqNumber;
     this.SOBId = entity.SOBId;
     this.StartDate = entity.StartDate;
 }
 public CalendarViewModel(Calendar entity)
 {
     if (entity != null)
     {
         this.Adjusting = entity.Adjusting;
         this.ClosingStatus = entity.ClosingStatus;
         this.EndDate = entity.EndDate;
         this.Id = entity.Id;
         this.PeriodName = entity.PeriodName;
         this.PeriodQuarter = entity.PeriodQuarter;
         this.PeriodYear = entity.PeriodYear;
         this.SeqNumber = entity.SeqNumber;
         this.SOBId = entity.SOBId;
         this.StartDate = entity.StartDate;
         this.CompanyId = entity.CompanyId;
         this.CreateBy = entity.CreateBy;
         this.CreateDate = entity.CreateDate;
         this.UpdateBy = entity.UpdateBy;
         this.UpdateDate = entity.UpdateDate;
     }
 }
 public string Update(Calendar entity)
 {
     return this.repository.Update(entity);
 }
 public string Insert(Calendar entity)
 {
     return this.repository.Insert(entity);
 }
 public string Insert(Calendar entity)
 {
     this.Context.Calendars.Add(entity);
     this.Commit();
     return entity.Id.ToString();
 }