Esempio n. 1
0
 private void ResetContactPerson()
 {
     SelectedContactPerson = new ContactPersonDTO
     {
         Sex = Sex.Male
     };
 }
 public ContactPersonEntry(ContactPersonDTO contactPersonDTO)
 {
     ContactPersonViewModel.Errors = 0;
     InitializeComponent();
     Messenger.Default.Send <ContactPersonDTO>(contactPersonDTO);
     Messenger.Reset();
 }
Esempio n. 3
0
        public async Task <ActionResult <ContactPersonDTO> > CreateContactPerson([FromBody] ContactPersonDTO contactPersonDTO)
        {
            try
            {
                if (contactPersonDTO == null)
                {
                    ModelState.AddModelError("ContactPerson", "ContactPerson object can't be null");
                    return(BadRequest(ModelState));
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                // validate customer.
                var customer = _choiceRepoistory.GetById <Customer>(c => c.AccountId == contactPersonDTO.AccountId);

                if (customer == null)
                {
                    return(NotFound(contactPersonDTO.AccountId));
                }
                contactPersonDTO.CustomerId = customer.CustomerId;

                var contactPersonInDb = _choiceRepoistory.GetById <ContactPerson>(c => c.ContactId == contactPersonDTO.ContactId);
                if (contactPersonInDb != null)
                {
                    ModelState.AddModelError("ContactPerson", $"ContactPerson entry already exist for ContactId {contactPersonDTO.ContactId}.");
                    return(BadRequest(ModelState));
                }

                ContactPerson newContactPerson = _mapper.Map <ContactPersonDTO, ContactPerson>(contactPersonDTO);
                newContactPerson.CreatedBy      = "CRM";
                newContactPerson.CreatedDate    = DateTime.UtcNow;
                newContactPerson.LastModified   = DateTime.UtcNow;
                newContactPerson.LastModifiedBy = "CRM";

                if (bool.Parse(_configuration["SharePointIntegrationEnabled"].ToString()))
                {
                    var sharePointId = await _sharePointService.InsertCustomerContactAsync(newContactPerson, _choiceRepoistory.GetById <Customer>(c => c.AccountId == newContactPerson.AccountId)).ConfigureAwait(false);

                    if (sharePointId <= 0)
                    {
                        return(StatusCode(500, "An error occurred while creating sharepoint customer contact. Please try again or contact adminstrator"));
                    }
                    newContactPerson.SharePointId = sharePointId;
                }
                _choiceRepoistory.Attach <ContactPerson>(newContactPerson);
                _choiceRepoistory.Complete();
                return(CreatedAtRoute("GetContactPersonByContactId", new { newContactPerson.ContactId }, contactPersonDTO));
            }
            catch (Exception)
            {
                // TODO : Add logging and decide on showing ex.message
                return(StatusCode(500, "An error occurred while creating ContactPerson. Please try again or contact adminstrator"));
            }
        }
Esempio n. 4
0
        public ContactPerson FromContactPersonDTOTOContactPerson(ContactPersonDTO contactPersonDTO)
        {
            ContactPerson contactPerson = ContactPerson.CreateNewContactPerson(
                contactPersonDTO.FirstName,
                contactPersonDTO.LastName,
                _addressMapper.DTOToAddress(contactPersonDTO.Address),
                contactPersonDTO.Email,
                contactPersonDTO.PhoneNumber,
                contactPersonDTO.MobilePhoneNumber);

            return(contactPerson);
        }
Esempio n. 5
0
        public ContactPersonDTO FromContactPersonTOContactPersonDTO(ContactPerson contactPerson)
        {
            var contactPersonDTO = new ContactPersonDTO
            {
                Address           = _addressMapper.AddressToDTO(contactPerson.Address),
                Email             = contactPerson.Email,
                FirstName         = contactPerson.FirstName,
                LastName          = contactPerson.LastName,
                MobilePhoneNumber = contactPerson.MobilePhoneNumber,
                PhoneNumber       = contactPerson.PhoneNumber
            };

            return(contactPersonDTO);
        }
Esempio n. 6
0
        public void GivenFromContactPersonDTOTOContactPerson_WhenGivenContactPersonDTO_ThenCreateContactPerson()
        {
            var memstub    = Substitute.For <IMemberServices>();
            var stubMapper = Substitute.For <IContactPersonMapper>();
            ContactPersonMapper cmapper = new ContactPersonMapper(new AddressMapper(new CityMapper(memstub)));
            var cityDTO = new CityDTO {
                ZIP = 2050, CityName = "Antwerpen", CountryName = "Belgium"
            };

            var addres = new AddressDTO {
                StreetName = "teststreet", StreetNumber = "58", CityDTO = cityDTO
            };
            var contactPerson = new ContactPersonDTO {
                FirstName = "lars", Address = addres, Email = "*****@*****.**", LastName = "peelman", MobilePhoneNumber = "55555", PhoneNumber = "55555"
            };

            var result = cmapper.FromContactPersonDTOTOContactPerson(contactPerson);

            Assert.IsType <ContactPerson>(result);
        }
Esempio n. 7
0
        public void GivenFromParkingLotCreateToParkingLotWithoutBuildingType_WhenLeavingBuildingTypeEmpty_ThenBuildingTypeisDefaultAboveGround()
        {
            var memstub = Substitute.For <IMemberServices>();
            ParkingLotMapper parkmap = new ParkingLotMapper(new AddressMapper(new CityMapper(memstub)), new ContactPersonMapper(new AddressMapper(new CityMapper(memstub))));
            var cityDTO = new CityDTO {
                ZIP = 2050, CityName = "Antwerpen", CountryName = "Belgium"
            };
            var addres = new AddressDTO {
                StreetName = "teststreet", StreetNumber = "58", CityDTO = cityDTO
            };
            var contactPerson = new ContactPersonDTO {
                FirstName = "lars", Address = addres, Email = "*****@*****.**", LastName = "peelman", MobilePhoneNumber = "55555", PhoneNumber = "55555"
            };
            var parkinglotDTO = new ParkingLotDTO_Create {
                Address = addres, Capacity = 5, ContactPerson = contactPerson, DivisionID = new Guid(), Name = "lasr", PricePerHour = 5.00M
            };

            var result = parkmap.FromParkingLotCreateToParkingLot(parkinglotDTO);

            Assert.Equal("AboveGround", result.BuildingType.ToString());
        }
Esempio n. 8
0
        public void GivenCreateParkingLotFromParkingLotDTO_WhenGivenParkinglotToCreate_ThenCreateParkingLot()
        {
            var memstub              = Substitute.For <IMemberServices>();
            var stubpark             = Substitute.For <IParkingLotMapper>();
            ParkingLotMapper parkmap = new ParkingLotMapper(new AddressMapper(new CityMapper(memstub)), new ContactPersonMapper(new AddressMapper(new CityMapper(memstub))));
            var cityDTO              = new CityDTO {
                ZIP = 2050, CityName = "Antwerpen", CountryName = "Belgium"
            };

            var addres = new AddressDTO {
                StreetName = "teststreet", StreetNumber = "58", CityDTO = cityDTO
            };
            var contactPerson = new ContactPersonDTO {
                FirstName = "lars", Address = addres, Email = "*****@*****.**", LastName = "peelman", MobilePhoneNumber = "55555", PhoneNumber = "55555"
            };

            var parkinglotDTO = new ParkingLotDTO_Create {
                Address = addres, Buildingtype = BuildingType.AboveGround.ToString(), Capacity = 5, ContactPerson = contactPerson, DivisionID = new Guid(), Name = "lasr", PricePerHour = 5.00M
            };
            var result = parkmap.FromParkingLotCreateToParkingLot(parkinglotDTO);

            Assert.IsType <ParkingLot>(result);
        }