Esempio n. 1
0
        /// <summary>
        /// Converts a <see cref="T:HospitalAllocation.Data.Allocation.Positions.Position"/>
        /// to a <see cref="T:HospitalAllocation.Providers.Allocation.Database.Model.Position"/>.
        /// </summary>
        /// <param name="position">The position to convert.</param>
        /// <param name="type">The type of the position.</param>
        /// <returns>The converted position.</returns>
        public Position PositionToModel(DataPositions.Position position, PositionType type)
        {
            if (position is DataPositions.IdentifiedPosition)
            {
                int?staffId = LookupModelStaffId((position as DataPositions.IdentifiedPosition).StaffId);

                if (staffId != null)
                {
                    return(new Position()
                    {
                        Type = type,
                        ShiftType = ShiftTypeToModel(position.ShiftType),
                        StaffPosition = new KnownStaffPosition
                        {
                            StaffMemberId = staffId
                        },
                    });
                }
                else
                {
                    throw new ArgumentException("Position data object could not be parsed to Position model object, illegal staffId supplied.");
                }
            }
            return(new Position
            {
                Type = type,
                ShiftType = ShiftTypeToModel(position.ShiftType),
                StaffPosition = new UnknownStaffPosition
                {
                    StaffName = (position as DataPositions.UnidentifiedPosition).StaffName
                },
            });
        }
Esempio n. 2
0
 /// <summary>
 /// Converts a bed <see cref="T:HospitalAllocation.Data.Allocation.Positions.Position"/>
 /// to a <see cref="T:HospitalAllocation.Providers.Allocation.Database.Model.BedPosition"/>.
 /// </summary>
 /// <param name="bedId">The id of the bed.</param>
 /// <param name="position">The bed.</param>
 /// <returns>The converted bed.</returns>
 public BedPosition BedToModel(int bedId, DataPositions.Position position)
 {
     if (position is DataPositions.IdentifiedPosition)
     {
         int?staffId = LookupModelStaffId((position as DataPositions.IdentifiedPosition).StaffId);
         if (staffId != null)
         {
             return(new BedPosition
             {
                 Type = PositionType.Bed,
                 Position = bedId,
                 ShiftType = ShiftTypeToModel(position.ShiftType),
                 StaffPosition = new KnownStaffPosition
                 {
                     StaffMemberId = staffId
                 },
             });
         }
     }
     else if (position is DataPositions.UnidentifiedPosition)
     {
         var staffName = (position as DataPositions.UnidentifiedPosition).StaffName;
         return(new BedPosition()
         {
             Type = PositionType.Bed,
             Position = bedId,
             ShiftType = ShiftTypeToModel(position.ShiftType),
             StaffPosition = new UnknownStaffPosition
             {
                 StaffName = staffName
             },
         });
     }
     throw new ArgumentException("Invalid Staff position supplied");
 }