public PurchaseOrderModel(PurchaseOrder entity)
 {
     if (entity != null)
     {
         this.BuyerId = entity.BuyerId;
         this.CompanyId = entity.CompanyId;
         this.CreateBy = entity.CreateBy;
         this.CreateDate = entity.CreateDate;
         this.Description = entity.Description;
         this.Id = entity.Id;
         this.PODate = entity.PODate;
         this.PONo = entity.PONo;
         this.SOBId = entity.SOBId;
         this.Status = entity.Status;
         this.UpdateBy = entity.UpdateBy;
         this.UpdateDate = entity.UpdateDate;
         this.VendorId = entity.VendorId;
         this.VendorSiteId = entity.VendorSiteId;
     }
 }
        private PurchaseOrder getEntityByModel(PurchaseOrderModel model)
        {
            if (model == null) return null;

            PurchaseOrder entity = new PurchaseOrder();

            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.BuyerId = model.BuyerId;
            entity.CompanyId = model.CompanyId;
            entity.CreateBy = model.CreateBy;
            entity.CreateDate = model.CreateDate;
            entity.Description = model.Description;
            entity.Id = model.Id;
            entity.PODate = model.PODate;
            entity.PONo = model.PONo;
            entity.SOBId = model.SOBId;
            entity.Status = model.Status;
            entity.UpdateBy = model.UpdateBy;
            entity.UpdateDate = model.UpdateDate;
            entity.VendorId = model.VendorId;
            entity.VendorSiteId = model.VendorSiteId;

            return entity;
        }
 public string Insert(PurchaseOrder entity)
 {
     this.Context.PurchaseOrders.Add(entity);
     this.Commit();
     return entity.Id.ToString();
 }
 public string Update(PurchaseOrder entity)
 {
     var originalEntity = this.Context.PurchaseOrders.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(PurchaseOrder entity)
 {
     return this.repository.Update(entity);
 }
 public string Insert(PurchaseOrder entity)
 {
     return this.repository.Insert(entity);
 }