Ejemplo n.º 1
0
        public async Task <IHttpActionResult> UpdateAsync(RoomContract room)
        {
            try
            {
                await roomService.UpdateAsync(room.ToModel());

                return(Content(HttpStatusCode.Accepted, room.RoomId));
            }
            catch (KeyNotFoundException)
            {
                return(NotFound());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Maps model to contract
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static RoomContract ToContract(this Room model)
        {
            if (model == null)
            {
                return(null);
            }

            var result = new RoomContract();

            result.InjectFrom(model);

            // Map any non-identical properties here
            //result.LookupName = LookupDataNameById(model.LookupDataId);

            return(result);
        }
Ejemplo n.º 3
0
        /*========================================*/

        /// <summary>
        /// Maps contract to model
        /// </summary>
        /// <param name="contract"></param>
        /// <returns></returns>
        public static Room ToModel(this RoomContract contract)
        {
            if (contract == null)
            {
                return(null);
            }

            var result = new Room();

            result.InjectFrom(contract);

            result.RoomBeds = contract.RoomBeds.Select(b => new RoomBed().InjectFrom(b)).Cast <RoomBed>().ToList();

            //result[i].Reservations = modelList[i].Reservations.Select(
            //    b => new ReservationContract().InjectFrom(b)).Cast<ReservationContract>().ToList();

            return(result);
        }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> AddAsync(RoomContract room)
        {
            await roomService.AddAsync(room.ToModel());

            return(Created(new Uri(Request.RequestUri, room.RoomId.ToString()), room.RoomId));
        }
Ejemplo n.º 5
0
 public SlimRoomContract(RoomContract roomContract)
 {
     MealPlan     = roomContract.MealPlan;
     ContractType = roomContract.ContractDescription;
     BoardBasis   = roomContract.BoardBasis;
 }