private static LocatorWarehouse getEntityByModel(LocatorWarehouseModel model, int count) { if (model == null) { return(null); } LocatorWarehouse entity = new LocatorWarehouse(); if (count == 0) { entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; } entity.EndDate = model.EndDate; entity.Id = model.Id; entity.LocatorId = model.LocatorId; entity.SOBId = model.SOBId; entity.StartDate = model.StartDate; entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; entity.WarehouseId = model.WarehouseId; return(entity); }
public long Update(LocatorWarehouse entity) { LocatorWarehouse originalEntity = this.Context.LocatorWarehouses.Find(entity.Id); this.Context.Entry(originalEntity).CurrentValues.SetValues(entity); this.Context.Entry(originalEntity).State = EntityState.Modified; this.Commit(); return(entity.Id); }
public LocatorWarehouseModel(LocatorWarehouse entity) { this.CreateBy = entity.CreateBy; this.CreateDate = entity.CreateDate; this.EndDate = entity.EndDate; this.Id = entity.Id; this.LocatorId = entity.LocatorId; this.SOBId = entity.SOBId; this.StartDate = entity.StartDate; this.UpdateBy = entity.UpdateBy; this.UpdateDate = entity.UpdateDate; this.WarehouseId = entity.WarehouseId; }
public static void Save(LocatorModel locatorModel) { Locator entity = getEntityByModel(locatorModel); string result = string.Empty; if (entity.IsValid()) { if (locatorModel.Id > 0) { result = service.Update(entity); } else { result = service.Insert(entity); } if (!string.IsNullOrEmpty(result)) { var savedDetail = GetLocatorWarehouses(result); if (savedDetail.Count() > locatorModel.LocatorWarehouses.Count()) { var tobeDeleted = savedDetail.Take(savedDetail.Count() - locatorModel.LocatorWarehouses.Count()); foreach (var item in tobeDeleted) { service.DeleteLocatorWarehouse(item.Id); } savedDetail = GetLocatorWarehouses(result); } foreach (var detail in locatorModel.LocatorWarehouses) { LocatorWarehouse detailEntity = getEntityByModel(detail, 0); if (detailEntity.IsValid()) { detailEntity.LocatorId = Convert.ToInt64(result); if (savedDetail.Count() > 0) { detailEntity.Id = savedDetail.FirstOrDefault().Id; savedDetail.Remove(savedDetail.FirstOrDefault(rec => rec.Id == detailEntity.Id)); service.Update(detailEntity); } else { service.Insert(detailEntity); } } } } } }
public long Insert(LocatorWarehouse entity) { this.Context.LocatorWarehouses.Add(entity); this.Commit(); return(entity.Id); }
public LocatorWarehouse GetSingle(long id) { LocatorWarehouse locatorWarehouse = this.Context.LocatorWarehouses.FirstOrDefault(x => x.Id == id); return(locatorWarehouse); }
public long Update(LocatorWarehouse entity) { return(this.repository.Update(entity)); }
public long Insert(LocatorWarehouse entity) { return(this.repository.Insert(entity)); }