/// <summary>
        /// method to get the active housingcomplexes
        /// </summary>
        /// <returns></returns>
        public async Task <List <HousingComplexDto> > HousingComplexsGetActive()
        {
            HousingComplex housingComplexVnM = new HousingComplex();
            var            dtoComplexes      = await housingComplexVnM.getActiveDtoList(await graceService.GetComplexesAsync());

            //STILL NEED TO VALIDATE
            return(dtoComplexes);
        }
        /// <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)));
        }
        public bool Validate(HousingComplex housing)
        {
            if (val.StringValidate(housing.Address, 500) &&
                val.PrimaryKeyValidate(housing.HotelID) &&
                val.StringValidate(housing.Name, 200) &&
                val.StringValidate(housing.PhoneNumber, 20))
            {
                return(true);
            }


            return(false);
        }
        /// <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)));
            }
        }
示例#6
0
        /// <summary>
        /// these methods map the daos to the entity objects and vice versa
        /// </summary>
        /// <returns></returns>


        public HousingComplexDao MapToService(HousingComplex housing)
        {
            var mapper = HousingComplexMapper.CreateMapper();

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