コード例 #1
0
        public ActionResult Details(Guid id)
        {
            CustomerCommunication item = _iCustomerCommunicationService.GetById(id);

            ViewBag.CustomerId = item.Customer.CustomerName;
            return(View(item));
        }
コード例 #2
0
        //
        // GET: /Platform/SysDepartment/Edit/5

        public ActionResult Edit(Guid?id)
        {
            var item = new CustomerCommunication();

            if (id.HasValue)
            {
                item = _iCustomerCommunicationService.GetById(id.Value);
            }
            ViewBag.CustomerId = new SelectList(_iCustomerService.GetAll(), "Id", "CustomerName", item.CustomerId);
            return(View(item));
        }
コード例 #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="customerCommunication">A customer communication instance to base the model on</param>
 public CustomerCommunicationModel(CustomerCommunication customerCommunication)
 {
     if (customerCommunication != null)
     {
         this.Id                = customerCommunication.Id;
         this.CustomerId        = customerCommunication.CustomerId;
         this.CommunicationType = customerCommunication.CommunicationType;
         this.CommunicationTime = customerCommunication.CommunicationTime;
         this.Detail            = customerCommunication.Detail;
     }
 }
コード例 #4
0
        public void MapEntityToModelList()
        {
            var mapper = new DALCustomerCommunicationMapper();
            CustomerCommunication item = new CustomerCommunication();

            item.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A");
            List <ApiCustomerCommunicationServerResponseModel> response = mapper.MapEntityToModel(new List <CustomerCommunication>()
            {
                { item }
            });

            response.Count.Should().Be(1);
        }
コード例 #5
0
        public void MapModelToEntity()
        {
            var mapper = new DALCustomerCommunicationMapper();
            ApiCustomerCommunicationServerRequestModel model = new ApiCustomerCommunicationServerRequestModel();

            model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A");
            CustomerCommunication response = mapper.MapModelToEntity(1, model);

            response.CustomerId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.EmployeeId.Should().Be(1);
            response.Notes.Should().Be("A");
        }
コード例 #6
0
        public virtual async Task <ApiCustomerCommunicationServerResponseModel> Get(int id)
        {
            CustomerCommunication record = await this.CustomerCommunicationRepository.Get(id);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.DalCustomerCommunicationMapper.MapEntityToModel(record));
            }
        }
コード例 #7
0
        /// <summary>
        /// Get a CustomerCommunication representation of the CustomerCommunicationModel class
        /// </summary>
        /// <returns>The customer communication</returns>
        public CustomerCommunication ToCustomerCommunication()
        {
            var customer = new CustomerCommunication()
            {
                Id                = this.Id,
                CustomerId        = this.CustomerId,
                CommunicationType = this.CommunicationType,
                CommunicationTime = this.CommunicationTime,
                Detail            = this.Detail
            };

            return(customer);
        }
コード例 #8
0
        public void MapEntityToModel()
        {
            var mapper = new DALCustomerCommunicationMapper();
            CustomerCommunication item = new CustomerCommunication();

            item.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A");
            ApiCustomerCommunicationServerResponseModel response = mapper.MapEntityToModel(item);

            response.CustomerId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.EmployeeId.Should().Be(1);
            response.Id.Should().Be(1);
            response.Notes.Should().Be("A");
        }
コード例 #9
0
        public ActionResult Edit(Guid?id, CustomerCommunication collection)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.CustomerId = new SelectList(_iCustomerService.GetAll(), "Id", "CustomerName",
                                                    collection.CustomerId);
                return(View(collection));
            }

            _iCustomerCommunicationService.Save(id, collection);
            _unitOfWork.Commit();

            return(RedirectToAction("Index"));
        }
コード例 #10
0
        public virtual CustomerCommunication MapModelToEntity(
            int id,
            ApiCustomerCommunicationServerRequestModel model
            )
        {
            CustomerCommunication item = new CustomerCommunication();

            item.SetProperties(
                id,
                model.CustomerId,
                model.DateCreated,
                model.EmployeeId,
                model.Notes);
            return(item);
        }
コード例 #11
0
        public virtual async Task <CreateResponse <ApiCustomerCommunicationServerResponseModel> > Create(
            ApiCustomerCommunicationServerRequestModel model)
        {
            CreateResponse <ApiCustomerCommunicationServerResponseModel> response = ValidationResponseFactory <ApiCustomerCommunicationServerResponseModel> .CreateResponse(await this.CustomerCommunicationModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                CustomerCommunication record = this.DalCustomerCommunicationMapper.MapModelToEntity(default(int), model);
                record = await this.CustomerCommunicationRepository.Create(record);

                response.SetRecord(this.DalCustomerCommunicationMapper.MapEntityToModel(record));
                await this.mediator.Publish(new CustomerCommunicationCreatedNotification(response.Record));
            }

            return(response);
        }
コード例 #12
0
        public async void Get_ShouldReturnRecords()
        {
            var mock   = new ServiceMockFacade <ICustomerCommunicationService, ICustomerCommunicationRepository>();
            var record = new CustomerCommunication();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new CustomerCommunicationService(mock.LoggerMock.Object,
                                                           mock.MediatorMock.Object,
                                                           mock.RepositoryMock.Object,
                                                           mock.ModelValidatorMockFactory.CustomerCommunicationModelValidatorMock.Object,
                                                           mock.DALMapperMockFactory.DALCustomerCommunicationMapperMock);

            ApiCustomerCommunicationServerResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
コード例 #13
0
        public virtual ApiCustomerCommunicationServerResponseModel MapEntityToModel(
            CustomerCommunication item)
        {
            var model = new ApiCustomerCommunicationServerResponseModel();

            model.SetProperties(item.Id,
                                item.CustomerId,
                                item.DateCreated,
                                item.EmployeeId,
                                item.Notes);
            if (item.CustomerIdNavigation != null)
            {
                var customerIdModel = new ApiCustomerServerResponseModel();
                customerIdModel.SetProperties(
                    item.CustomerIdNavigation.Id,
                    item.CustomerIdNavigation.Email,
                    item.CustomerIdNavigation.FirstName,
                    item.CustomerIdNavigation.LastName,
                    item.CustomerIdNavigation.Notes,
                    item.CustomerIdNavigation.Phone);

                model.SetCustomerIdNavigation(customerIdModel);
            }

            if (item.EmployeeIdNavigation != null)
            {
                var employeeIdModel = new ApiEmployeeServerResponseModel();
                employeeIdModel.SetProperties(
                    item.EmployeeIdNavigation.Id,
                    item.EmployeeIdNavigation.FirstName,
                    item.EmployeeIdNavigation.IsSalesPerson,
                    item.EmployeeIdNavigation.IsShipper,
                    item.EmployeeIdNavigation.LastName);

                model.SetEmployeeIdNavigation(employeeIdModel);
            }

            return(model);
        }
コード例 #14
0
        public virtual async Task <UpdateResponse <ApiCustomerCommunicationServerResponseModel> > Update(
            int id,
            ApiCustomerCommunicationServerRequestModel model)
        {
            var validationResult = await this.CustomerCommunicationModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                CustomerCommunication record = this.DalCustomerCommunicationMapper.MapModelToEntity(id, model);
                await this.CustomerCommunicationRepository.Update(record);

                record = await this.CustomerCommunicationRepository.Get(id);

                ApiCustomerCommunicationServerResponseModel apiModel = this.DalCustomerCommunicationMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CustomerCommunicationUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiCustomerCommunicationServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiCustomerCommunicationServerResponseModel> .UpdateResponse(validationResult));
            }
        }
コード例 #15
0
        public async Task SeedAsync()
        {
            //await _context.Database.MigrateAsync().ConfigureAwait(false);

            if (!await _context.Customers.AnyAsync())
            {
                _logger.LogInformation("Seeding initial data");

                // Customer 1
                Customer customer1 = new Customer
                {
                    Id        = 1,
                    FirstName = "John",
                    Surname   = "Smith",
                    Address   = "Address1",
                    Email     = "*****@*****.**",
                    Phone     = "2222222"
                };

                CustomerCommunication comm1_1 = new CustomerCommunication
                {
                    Id                = 1,
                    CustomerId        = customer1.Id,
                    CommunicationType = Core.CommunicationType.Email,
                    CommunicationTime = DateTime.UtcNow,
                    Detail            = "Quotation Request"
                };

                _context.Customers.Add(customer1);
                _context.CustomerCommunications.Add(comm1_1);

                // Customer 2
                Customer customer2 = new Customer
                {
                    Id        = 2,
                    FirstName = "Dave",
                    Surname   = "Jones",
                    Address   = "Address1",
                    Email     = "*****@*****.**",
                    Phone     = "7777777"
                };

                CustomerCommunication comm2_1 = new CustomerCommunication
                {
                    Id                = 2,
                    CustomerId        = customer2.Id,
                    CommunicationType = Core.CommunicationType.Email,
                    CommunicationTime = DateTime.UtcNow,
                    Detail            = "Quotation Request"
                };

                CustomerCommunication comm2_2 = new CustomerCommunication
                {
                    Id                = 3,
                    CustomerId        = customer2.Id,
                    CommunicationType = Core.CommunicationType.Email,
                    CommunicationTime = DateTime.UtcNow,
                    Detail            = "Quotation Request 2"
                };

                _context.Customers.Add(customer2);
                _context.CustomerCommunications.Add(comm2_1);
                _context.CustomerCommunications.Add(comm2_2);

                await _context.SaveChangesAsync();

                _logger.LogInformation("Seeding initial data completed");
            }
        }
コード例 #16
0
ファイル: UsersController.cs プロジェクト: huangal/Banking
 public IActionResult CreateContact([FromBody] CustomerCommunication communication)
 {
     return(Ok(communication));
 }