Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
        public ActionResult CreateHub(HubViewModel vm)
        {
            ViewBag.RegionList = _hubViewModelBuilder.Region();
            ViewBag.ContactList = _hubViewModelBuilder.Contact();
            ViewBag.ParentCostCentreList = _hubViewModelBuilder.ParentCostCentre();

            try
            {
                vm.Id = Guid.NewGuid();
                _hubViewModelBuilder.Save(vm);

                TempData["msg"] = "Hub Successfully Created";

                return RedirectToAction("ListHubs");
            }
            catch (DomainValidationException ve)
            {
                TempData["msg"] = ve.Message;
                ValidationSummary.DomainValidationErrors(ve, ModelState);
                _log.Debug("Failed to create commodity producers " + ve.Message);
                _log.Error("Failed to create commodity producers" + ve.ToString());

                return View(vm);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                _log.Debug("Failed to create Commodity producers " + ex.Message);
                _log.Error("Failed to create Commodity producers" + ex.ToString());

                return View(vm);
            }

        }