Beispiel #1
0
 public OfficeVM(OfficeDTO row)
 {
     OfficeId    = row.OfficeId;
     Name        = row.Name;
     Description = row.Description;
     Preference  = row.Preference;
 }
Beispiel #2
0
        public void Update(OfficeDTO office)
        {
            var item = _mapper.Map <OfficeDTO, Domain.Entities.Office>(office);

            _repository.Update(item);
            _unitOfWork.SaveChanges();
        }
        public void CreateNewOffice(OfficeDTO officeDTO)
        {
            Expression <Func <Office, bool> > expressionPredicate = o => o.Id == officeDTO.Id;
            var office = this._uoW.OfficeRepository.Find(expressionPredicate).FirstOrDefault();

            if (office != null)
            {
                throw new Exception("Office with this ID already exists");
            }

            var postalCode = new PostalCode(officeDTO.Address.PostalCode.FirstPart, officeDTO.Address.PostalCode.SecondPart);
            var dialCode   = new DialCode(officeDTO.PhoneNumber.AreaCode.Prefix, officeDTO.PhoneNumber.AreaCode.Country, officeDTO.PhoneNumber.AreaCode.Code);

            var address = new Address(officeDTO.Address.Locality, officeDTO.Address.Province, officeDTO.Address.Parish, officeDTO.Address.County, postalCode, officeDTO.Address.Country, officeDTO.Address.Street,
                                      officeDTO.Address.BuildingNumber, officeDTO.Address.LocalNumber);
            var phoneNumber = new PhoneNumber(officeDTO.PhoneNumber.Number, dialCode);

            office = new Office(
                officeDTO.Id,
                officeDTO.Director,
                address,
                officeDTO.OpenFrom,
                officeDTO.OpenTo,
                (OpenClose)officeDTO.IsOpen,
                phoneNumber,
                _domainEventPublisher
                );

            _uoW.OfficeRepository.Insert(office);
            _uoW.Commit();
        }
Beispiel #4
0
 public OfficeDetails()
 {
     InitializeComponent();
     DTO    = new OfficeDTO();
     sqlCon = new SqlConnection("Data Source=DESKTOP-63Q74F5;Initial Catalog=Project;Integrated Security=True");
     cmd    = new SqlCommand();
 }
Beispiel #5
0
        public Domain.Entities.Office Add(OfficeDTO office)
        {
            var item = _mapper.Map <OfficeDTO, Domain.Entities.Office>(office);

            _repository.Insert(item);
            _unitOfWork.SaveChanges();
            return(item);
        }
 public RegionDTO(Region region, DBC dbc)
 {
     RegionID         = region.RegionID;
     RegionName       = region.RegionName;
     RegionHeadOffice = new OfficeDTO(dbc
                                      .Offices
                                      .Where(x => x.OfficeID == region.RegionHeadOfficeID)
                                      .FirstOrDefault(), dbc);
 }
Beispiel #7
0
        public IHttpActionResult Post([FromBody] OfficeDTO officeDto)
        {
            var ret = _officeService.AddNewOffice(officeDto: officeDto);

            if (ret == null)
            {
                return(BadRequest(message: _officeService.LastErrorMessage));
            }
            return(CreatedAtRoute(routeName: "DefaultApi", routeValues: new { id = ret.Id }, content: ret));
        }
Beispiel #8
0
 public IActionResult Edit([FromBody] OfficeDTO officeDTO)
 {
     if (ModelState.IsValid)
     {
         _officeService.Update(officeDTO);
         return(Ok(officeDTO));
     }
     else
     {
         return(BadRequest());
     }
 }
        public Guid CreateOffice(string director, string openFrom, string openTo)
        {
            var officeId = Guid.NewGuid();

            var postalCode = new PostalCodeDTO()
            {
                FirstPart  = "30",
                SecondPart = "002"
            };

            var address = new AddressDTO
            {
                PostalCode     = postalCode,
                Country        = "Poland",
                County         = "krakowski",
                Locality       = "Kraków",
                Street         = "Jana Pawła II",
                Province       = "małopolskie",
                Parish         = "Kraków",
                LocalNumber    = "2",
                BuildingNumber = "1"
            };

            var dialCode = new DialCodeDTO
            {
                Code    = "PL",
                Country = "Poland",
                Prefix  = "+48"
            };

            var phoneNumber = new PhoneNumberDTO
            {
                AreaCode = dialCode,
                Number   = "322655766"
            };

            var office = new OfficeDTO
            {
                Id          = officeId,
                PhoneNumber = phoneNumber,
                OpenFrom    = openFrom,
                OpenTo      = openTo,
                IsOpen      = OpenCloseDTO.Open,
                Address     = address,
                Director    = director
            };

            _officeService.CreateNewOffice(office);

            return(officeId);
        }
Beispiel #10
0
        public async Task <IActionResult> GetCompanyDetails(long id)
        {
            CarCompany company = await CarService.GetCompany(id);

            CarCompanyProfile companyProfile = new CarCompanyProfile();

            CarCompanyProfileDTO carCompanyProfileDTO = new CarCompanyProfileDTO();

            List <Office>  officeList    = company.Offices;
            List <Vehicle> vehicleList   = company.Vehicles;
            List <int>     vehicleRating = new List <int>();

            foreach (var vehicle in vehicleList)
            {
                vehicleRating.Add(await VehicleService.GetVehicleRatingAsInteger(vehicle.VehicleId));
            }

            int carCompanyRatingPicture = 0;

            if (ModelState.IsValid)
            {
                List <OfficeDTO> officeDTOList = new List <OfficeDTO>();

                for (int i = 0; i < officeList.Count; i++)
                {
                    OfficeDTO officeDTO = new OfficeDTO();

                    DestinationDTO destinationDTO = new DestinationDTO();

                    destinationDTO.Latitude  = officeList[i].Location.Latitude;
                    destinationDTO.Longitude = officeList[i].Location.Longitude;
                    destinationDTO.Name      = officeList[i].Location.Name;

                    officeDTO.OfficeId = officeList[i].OfficeId;
                    officeDTO.Location = destinationDTO;
                    officeDTO.Address  = officeList[i].Address;

                    officeDTOList.Add(officeDTO);
                }

                List <VehicleDTO> vehicleDTOList = new List <VehicleDTO>();

                for (int i = 0; i < vehicleList.Count; i++)
                {
                    VehicleDTO vehicleDTO = new VehicleDTO();

                    vehicleDTO.Additional   = vehicleList[i].Additional;
                    vehicleDTO.Baggage      = vehicleList[i].Baggage;
                    vehicleDTO.CarType      = vehicleList[i].CarType;
                    vehicleDTO.CostPerDay   = vehicleList[i].CostPerDay;
                    vehicleDTO.Doors        = vehicleList[i].Doors;
                    vehicleDTO.Fuel         = vehicleList[i].Fuel;
                    vehicleDTO.Name         = vehicleList[i].Name;
                    vehicleDTO.Passangers   = vehicleList[i].Passangers;
                    vehicleDTO.Rating       = vehicleRating[i];
                    vehicleDTO.Transmission = vehicleList[i].Transmission;
                    vehicleDTO.VehicleId    = vehicleList[i].VehicleId;
                    vehicleDTO.Additional   = vehicleList[i].Additional;

                    vehicleDTOList.Add(vehicleDTO);
                }

                string allOfficies = "";
                for (int i = 0; i < officeList.Count; i++)
                {
                    allOfficies += officeList[i].Location.Name + ",";
                }

                companyProfile = await CarService.GetCompanyProfile(id);

                carCompanyRatingPicture = await CarService.GetCompanyRatingAsInteger(id);

                carCompanyProfileDTO.Id            = company.CarCompanyId;
                carCompanyProfileDTO.Name          = companyProfile.Name;
                carCompanyProfileDTO.RatingPicture = carCompanyRatingPicture;
                carCompanyProfileDTO.Address       = companyProfile.Address;
                carCompanyProfileDTO.Description   = companyProfile.PromoDescription;
                carCompanyProfileDTO.OfficeList    = officeList;
                carCompanyProfileDTO.VehicleList   = vehicleDTOList;
                carCompanyProfileDTO.Offices       = allOfficies;

                return(Ok(new { carCompanyProfileDTO }));
            }
            ModelState.AddModelError("", "Cannot retrieve user data.");
            return(BadRequest(ModelState));
        }
Beispiel #11
0
 public IHttpActionResult Put([FromBody] OfficeDTO officeDto)
 {
     throw new NotImplementedException();
 }
Beispiel #12
0
 public IActionResult Add([FromBody] OfficeDTO officeDTO)
 {
     _officeService.Add(officeDTO);
     return(Ok(officeDTO));
 }