public string Update(Buyer entity)
 {
     if (entity.IsValid())
         return this.repository.Update(entity);
     else
         return "Entity is not in valid state";
 }
 private Buyer GetEntityByModel(BuyerModel model)
 {
     if (model == null) return null;
     Buyer entity = new Buyer();
     entity.Id = model.Id;
     entity.Name = model.Name;
     entity.SOBId = SessionHelper.SOBId;
     entity.StartDate = model.StartDate;
     entity.EndDate = model.EndDate;
     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.UpdateBy = AuthenticationHelper.UserId;
     entity.UpdateDate = DateTime.Now;
     return entity;
 }
 public string Update(Buyer entity)
 {
     var originalEntity = this.Context.Buyers.Find(entity.Id);
     this.Context.Entry(originalEntity).CurrentValues.SetValues(entity);
     this.Context.Entry(originalEntity).State = EntityState.Modified;
     this.Commit();
     return entity.Id.ToString();
 }
 public BuyerModel(Buyer entity)
 {
     this.Name = entity.Name;
     this.EndDate = entity.EndDate;
     this.Id = entity.Id;
     this.CompanyId = entity.CompanyId;
     this.StartDate = entity.StartDate;
     this.CreateBy = entity.CreateBy;
     this.CreateDate = entity.CreateDate;
     this.UpdateBy = entity.UpdateBy;
     this.UpdateDate = entity.UpdateDate;
 }
 public string Insert(Buyer entity)
 {
     this.Context.Buyers.Add(entity);
     this.Commit();
     return entity.Id.ToString();
 }