private static VendorSite GetEntityByModel(VendorSiteModel model) { if (model == null) { return(null); } VendorSite entity = new VendorSite(); entity.Id = model.Id; entity.Name = model.Name; entity.Address = model.Address; entity.CodeCombinationId = model.CodeCombinationId; entity.Contact = model.Contact; if (model.Id == 0) { entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; } entity.EndDate = model.EndDate; entity.StartDate = model.StartDate; entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; entity.VendorId = model.VendorId; return(entity); }
public static long Save(VendorSiteModel model) { VendorSite entity = GetEntityByModel(model); return(model.Id > 0 ? service.Update(entity) : service.Insert(entity)); }
public long Update(VendorSite entity) { var originalEntity = this.Context.VendorSites.Find(entity.Id); this.Context.Entry(originalEntity).CurrentValues.SetValues(entity); this.Context.Entry(originalEntity).State = EntityState.Modified; this.Commit(); return(entity.Id); }
public VendorSiteModel(VendorSite entity) { if (entity != null) { this.VendorId = entity.VendorId; this.CodeCombinationId = entity.CodeCombinationId; this.Address = entity.Address; this.Contact = entity.Contact; this.Name = entity.Name; this.EndDate = entity.EndDate; this.Id = entity.Id; this.StartDate = entity.StartDate; this.CreateBy = entity.CreateBy; this.CreateDate = entity.CreateDate; this.UpdateBy = entity.UpdateBy; this.UpdateDate = entity.UpdateDate; } }
public long Insert(VendorSite entity) { this.Context.VendorSites.Add(entity); this.Commit(); return(entity.Id); }
public long Update(VendorSite entity) { return(this.repository.Update(entity)); }
public long Insert(VendorSite entity) { return(this.repository.Insert(entity)); }