/// <summary>
        /// this method updates the HousingComplexDto
        /// </summary>
        /// <param name="fixComplex"></param>
        /// <returns>Task<bool></returns>
        public async Task <bool> UpdateHousingComplex(HousingComplexDto fixComplex)
        {
            HousingComplex housingComplexVnM = new HousingComplex();

            //validate the incoming DTO first before converting into DAO
            //STILL NEED TO VALIDATE

            return(await graceService.UpdateHousingComplexAsync(housingComplexVnM.MapToDao(fixComplex)));
        }
        /// <summary>
        /// This method returns a list of apartments within the given HousingComplex
        /// </summary>
        /// <param name="complex"></param>
        /// <returns>Task<List<ApartmentDto>></returns>
        public async Task <List <ApartmentDto> > FilterAptByComplex(HousingComplexDto complex)
        {
            List <ApartmentDto> returnList = new List <ApartmentDto>();

            foreach (var item in await ApartmentsGetActvie())
            {
                if (item.HotelID.Equals(complex.HotelID))
                {
                    returnList.Add(item);
                }
            }
            return(returnList);
        }
        /// <summary>
        /// method to give the current capacity of the given apartment complex
        /// </summary>
        /// <param name="hotApt"></param>
        /// <returns>Task<int></returns>
        public async Task <int> returnComplexMaxCap(HousingComplexDto hotApt)
        {
            int Total = 0;

            foreach (var item in await graceService.GetApartmentsAsync())
            {
                if (item.ActiveBit && (item.HotelID == hotApt.HotelID))
                {
                    Total += item.MaxCapacity;
                }
            }
            return(Total);
        }
 public async Task <HttpResponseMessage> Get([FromUri] HousingComplexDto complex)
 {
     try
     {
         var Response = Request.CreateResponse(HttpStatusCode.OK, await logicHelper.FilterAptByComplex(complex));
         log.Info("FilterAptsByComplex Get Successful");
         return(Response);
     }
     catch (Exception ex)
     {
         LogHelper.SendError(log, ex);
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
 }
        /// <summary>
        /// this method inserts a new complex by calling on the soap service.
        /// The "graceService.insert" returns a bool value so we just return
        /// that since it depends on its pass or fail
        /// </summary>
        /// <param name="newComplex"></param>
        /// <returns>Task<bool></returns>
        public async Task <bool> AddHousingComplex(HousingComplexDto newComplex)
        {
            try
            {
                HousingComplex housingComplexVnM = new HousingComplex();

                //validate the incoming DTO first before converting into DAO
                //STILL NEED TO VALIDATE

                return(await graceService.InsertHousingComplexAsync(housingComplexVnM.MapToDao(newComplex)));
            }
            catch (Exception)
            {
                return(false);
            }
        }
        /// <summary>
        /// This method recieves an HousingComlexDto model that we expect to delete based off of the primary key
        /// </summary>
        /// <param name="oldComplex"></param>
        /// <returns>Task<bool></returns>
        public async Task <bool> DeleteComplex(HousingComplexDto oldComplex)
        {
            HousingComplex housingComplexVnM = new HousingComplex();

            //validate the incoming DTO first before converting into DAO
            //STILL NEED TO VALIDATE

            //first we get the currentOccupancy, if its greater then ZERO then return false
            int currOccupancy = await housingComplexVnM.returnComplexCurCap(oldComplex);

            if (currOccupancy > 0)
            {
                return(false);
            }

            else
            {
                return(await graceService.DeleteHousingComplexAsync(housingComplexVnM.MapToDao(oldComplex)));
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// put method for HousingComplex
 /// </summary>
 /// <param name="complex"></param>
 /// <returns></returns>
 public async Task <HttpResponseMessage> Put([FromBody] HousingComplexDto complex)
 {
     try
     {
         if (await logicHelper.UpdateHousingComplex(complex))
         {
             var Response1 = Request.CreateResponse(HttpStatusCode.OK, "successfully updated");
             log.Info("HousingComplex Put Successful");
             return(Response1);
         }
         var Response2 = Request.CreateResponse(HttpStatusCode.BadRequest, "failed to update");
         log.Info("HousingComplex Put Unsuccessful");
         return(Response2);
     }
     catch (Exception ex)
     {
         LogHelper.SendError(log, ex);
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// post method to insert a new complex
 /// </summary>
 /// <param name="newHousingComDto"></param>
 /// <returns></returns>
 public async Task <HttpResponseMessage> Post([FromBody] HousingComplexDto newHousingComDto)
 {
     try
     {
         newHousingComDto.ActiveBit = true;
         if (await logicHelper.AddHousingComplex(newHousingComDto))
         {
             var Response1 = Request.CreateResponse(HttpStatusCode.OK, "successfully inserted");
             log.Info("HousingComplex Post Successful");
             return(Response1);
         }
         var Response2 = Request.CreateResponse(HttpStatusCode.BadRequest, "failed to insert");
         log.Info("HousingComplex Post Unsuccessful");
         return(Response2);
     }
     catch (Exception ex)
     {
         LogHelper.SendError(log, ex);
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
 }
        /// <summary>
        /// This method maps from a HousingComplexDto to a HousingComplexDao
        /// </summary>
        /// <param name="complex"></param>
        /// <returns>HousingComplexDao</returns>
        public HousingComplexDao MapToDao(HousingComplexDto complex)
        {
            var mapper = complexMapper.CreateMapper();

            return(mapper.Map <HousingComplexDao>(complex));
        }