public void Save(HubViewModel hubViewModel) { Hub hub = new Hub(hubViewModel.Id); hub.Name = hubViewModel.Name; hub.CostCentreCode = hubViewModel.CostCentreCode; hub.Region = _regionRepository.GetById(hubViewModel.RegionId); hub.VatRegistrationNo = hubViewModel.VatRegistrationNo; hub.Longitude = hubViewModel.Longitude; hub.Region = _regionRepository.GetById(hubViewModel.RegionId); hub.Latitude = hubViewModel.Latitude; hub._Status = EntityStatus.Active; hub.ParentCostCentre = new CostCentreRef {Id = hubViewModel.ParentCostCentreId}; hub.CostCentreType = CostCentreType.Hub; _hubRepository.Save(hub); }
private HubViewModel Map(Hub hub) { HubViewModel hubVM = new HubViewModel(); hubVM.Id = hub.Id; hubVM.CostCentreCode = hub.CostCentreCode; hubVM.RegionId = hub.Region.Id; hubVM.RegionName = hub.Region.Name; hubVM.Name = hub.Name; hubVM.VatRegistrationNo = hub.VatRegistrationNo; hubVM.Longitude = hub.Longitude; hubVM.Latitude = hub.Latitude; hubVM.ParentCostCentreId = hub.ParentCostCentre.Id; hubVM.IsActive = (int) hub._Status; hubVM.CanEditHubRegion = _masterDataUsage.CanEditHubOrDistributrRegion(hub); return hubVM; }
public HubDTO Map(Hub hub) { if (hub == null) return null; var hubDto = Mapper.Map<Hub, HubDTO>(hub); return hubDto; }
public bool CheckHubIsUsed(Hub hub, EntityStatus intendedStatus) { if (intendedStatus == EntityStatus.Inactive) { if (_ctx.tblCostCentre.Any(n => n.ParentCostCentreId == hub.Id && n.IM_Status == (int)EntityStatus.Active)) return true; } else if (intendedStatus == EntityStatus.Deleted) { if (_ctx.tblCostCentre.Any(n => n.ParentCostCentreId == hub.Id && (n.IM_Status == (int)EntityStatus.Active || n.IM_Status == (int)EntityStatus.Inactive))) return true; } return false; }
protected Guid AddHub(string code, string name, Guid regionId, string varNo, CostCentreRef parentCC) { Hub hub = new Hub(Guid.NewGuid()) { CostCentreCode = code, CostCentreType = CostCentreType.Hub, Name = name, Region = _regionRepository.GetById(regionId), VatRegistrationNo = varNo, _Status = EntityStatus.Active, ParentCostCentre = parentCC }; return _costCentreRepository.Save(hub); }
private void AssertCostCernter(Hub hubX, Hub hubY) { Assert.NotNull(hubX.Id); Assert.AreEqual(hubX.CostCentreType, hubY.CostCentreType); Assert.AreEqual(hubX.Name, hubY.Name); }