public virtual ActionResult Create(CarrierModel model) { if (string.IsNullOrWhiteSpace(model.Authentication.NewPassword)) { ModelState.AddModelError("NewPassword", Validation.EmplyPassword); } if (!ModelState.IsValid) { BindBag(); return(View()); } try { var id = _carriers.Add(model.Name, model.Email, model.Phone, model.Contact, model.Address, model.Authentication.Login, model.Authentication.NewPassword, _identity.Language); _carriers.SetCities(id, model.Cities); return(RedirectToAction(MVC.Carrier.Edit(id))); } catch (DublicateLoginException) { ModelState.AddModelError("Authentication.Login", Validation.LoginExists); BindBag(); return(View()); } }
public async Task <Guid> HandleAsync(CreateLegacyNotificationApplication message) { var notification = await notificationApplicationFactory.CreateLegacy( message.NotificationType, message.CompetentAuthority, message.Number); notificationApplicationRepository.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); var carrierCollection = new CarrierCollection(notification.Id); var producerCollection = new ProducerCollection(notification.Id); facilityRepository.Add(facilityCollection); carrierRepository.Add(carrierCollection); producerRepository.Add(producerCollection); await context.SaveChangesAsync(); return(notification.Id); }
public ActionResult Create(CarrierVm carrierViewModel) { if (ModelState.IsValid) { var carrier = Mapper.Map <CarrierVm, Carrier>(carrierViewModel); _carrierRepository.Add(carrier); return(RedirectToAction("Index")); } return(View(carrierViewModel)); }
public void Add_AnItemFromMockContext_() { Carrier Carrier = MockContext.Carriers.FirstOrDefault(); var mockCarrierSet = new Mock <DbSet <Carrier> >(); var mockEShopContext = new Mock <EShopContext>(); mockEShopContext.Setup(m => m.Carriers).Returns(mockCarrierSet.Object); Trace.WriteLine(Carrier.Phone); CarrierRepository = new CarrierRepository(mockEShopContext.Object); CarrierRepository.Add(Carrier); //mockCarrierSet.Verify(m => m.Add(It.IsAny<Carrier>()), Times.Once()); mockEShopContext.Verify(m => m.SaveChanges(), Times.Once()); }
public void AddOrUpdate(Carrier carrier) { Carrier person = _context.GetByName(carrier.Name); if (person == null) { _context.Add(carrier); } else { person.Name = carrier.Name; person.Logo = carrier.Logo; person.Phone = carrier.Phone; person.Status = carrier.Status; person.Code = carrier.Code; } _context.Complete(); }
public bool AddCarrier(CarrierModel carrier) { var entity = new Carrier() { Name = carrier.Name, AddressLine1 = carrier.AddressLine1, AddressLine2 = carrier.AddressLine2, City = carrier.City, State = carrier.State, ZipCode = carrier.ZipCode, Email = carrier.Email, Phone = carrier.Phone, IsActive = true, AddUser = LoginUserDetails.GetWindowsLoginUserName(), AddDate = DateUtil.GetCurrentDate() }; return(_carrierRepository.Add(entity)); }
public async Task <Guid> HandleAsync(CreateNotificationApplication command) { var authority = command.CompetentAuthority; var notification = await notificationApplicationFactory.CreateNew(command.NotificationType, authority); notificationApplicationRepository.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); var carrierCollection = new CarrierCollection(notification.Id); var producerCollection = new ProducerCollection(notification.Id); facilityRepository.Add(facilityCollection); carrierRepository.Add(carrierCollection); producerRepository.Add(producerCollection); await context.SaveChangesAsync(); return(notification.Id); }