public PurchasingPeriod GetSingle(string id, long companyId)
        {
            long             longId           = Convert.ToInt64(id);
            PurchasingPeriod purchasingPeriod = this.GetAll(companyId).FirstOrDefault(x => x.Id == longId);

            return(purchasingPeriod);
        }
Example #2
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);
        }
        public string Update(PurchasingPeriod entity)
        {
            var originalEntity = this.Context.PurchasingPeriods.Find(entity.Id);

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