Example #1
0
        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());
            }
        }
Example #2
0
        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);
        }
Example #3
0
        public ActionResult Create(CarrierVm carrierViewModel)
        {
            if (ModelState.IsValid)
            {
                var carrier = Mapper.Map <CarrierVm, Carrier>(carrierViewModel);
                _carrierRepository.Add(carrier);

                return(RedirectToAction("Index"));
            }

            return(View(carrierViewModel));
        }
Example #4
0
        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());
        }
Example #5
0
        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();
        }
Example #6
0
        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);
        }