Exemple #1
0
        /// <summary>
        /// Maps model to contract
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static RoomBedContract ToContract(this RoomBed model)
        {
            if (model == null)
            {
                return(null);
            }

            var result = new RoomBedContract();

            result.InjectFrom(model);

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

            return(result);
        }
Exemple #2
0
        /*========================================*/

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

            var result = new RoomBed();

            result.InjectFrom(contract);

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

            return(result);
        }
Exemple #3
0
        public async Task AddBedAsync(BedViewModel newBed, long roomId)
        {
            var room = await roomService.FindRoomByIdAsync(roomId);

            var bed = mapper.Map <BedViewModel, Bed>(newBed);
            await applicationContext.AddAsync(bed);

            await applicationContext.SaveChangesAsync();

            var roomBed = new RoomBed
            {
                Room   = room,
                RoomId = roomId,
                Bed    = bed,
                BedId  = bed.BedId
            };

            room.RoomBeds.Add(roomBed);

            await applicationContext.SaveChangesAsync();
        }
Exemple #4
0
        public async Task <RoomBed> AddBed(BedViewModel model)
        {
            var roomBedFromContext = await applicationContext.RoomBeds
                                     .Where(r => r.BedId == model.BedId && r.RoomId == model.RoomId)
                                     .SingleOrDefaultAsync();

            var roomBed = new RoomBed
            {
                RoomId    = model.RoomId,
                BedId     = model.BedId,
                BedNumber = model.BedNumber
            };

            if (roomBedFromContext == null)
            {
                await applicationContext.AddAsync(roomBed);

                await applicationContext.SaveChangesAsync();
            }
            return(roomBed);
        }