/// <summary>
        /// Creates a Availability from a ViewModel
        /// </summary>
        /// <param name="availabilityViewModel"></param>
        /// <returns></returns>
        public static Availability CreateAvailability(AvailabilityViewModel availabilityViewModel)
        {
            if (availabilityViewModel == null)
            {
                return(null);
            }
            Availability availability = new Availability(availabilityViewModel.Id)
            {
                ParticipationId = availabilityViewModel.ParticipationId,
                ShiftId         = availabilityViewModel.ShiftId,
                Type            = availabilityViewModel.Type,
                Preference      = availabilityViewModel.Preference,
                PushEmailSend   = availabilityViewModel.PushEmailSend,
                LastEditDate    = availabilityViewModel.LastEditDate,
                LastEditBy      = availabilityViewModel.LastEditBy,
                RowVersion      = availabilityViewModel.RowVersion
            };

            if (availabilityViewModel.Participation != null)
            {
                availability.Participation =
                    ParticipationViewModel.CreateParticipation(availabilityViewModel.Participation);
            }
            if (availabilityViewModel.Shift != null)
            {
                availability.Shift = ShiftViewModel.CreateShift(availabilityViewModel.Shift);
            }

            return(availability);
        }
Пример #2
0
        /// <summary>
        /// Creates a Participation from a ViewModel.
        /// </summary>
        /// <param name="participationViewModel"></param>
        /// <returns></returns>
        public static Participation CreateParticipation(ParticipationViewModel participationViewModel)
        {
            if (participationViewModel == null)
            {
                return(null);
            }

            Participation participation = new Participation(participationViewModel.Id)
            {
                MaxWorkingHoursPerWeek = participationViewModel.MaxWorkingHoursPerWeek,
                Availabilities         = participationViewModel.Availabilities,
                Remark       = participationViewModel.Remark,
                Active       = participationViewModel.Active,
                LastEditDate = participationViewModel.LastEditDate,
                LastEditBy   = participationViewModel.LastEditBy,
                RowVersion   = participationViewModel.RowVersion
            };

            if (participationViewModel.Person != null)
            {
                participation.Person   = PersonViewModel.CreatePerson(participationViewModel.Person);
                participation.PersonId = participationViewModel.Person.Id;
            }

            if (participationViewModel.Project == null)
            {
                return(participation);
            }
            participation.Project   = ProjectDetailsViewModel.CreateProject(participationViewModel.Project);
            participation.ProjectId = participationViewModel.Project.Id;

            return(participation);
        }
        /// <summary>
        /// Creates a ViewModel from a Availability
        /// </summary>
        /// <param name="availability"></param>
        /// <returns></returns>
        public static AvailabilityViewModel CreateVm(Availability availability)
        {
            if (availability == null)
            {
                return(null);
            }

            AvailabilityViewModel vm = new AvailabilityViewModel
            {
                Id = availability.Id,
                ParticipationId = availability.ParticipationId,
                ShiftId         = availability.ShiftId,
                Type            = availability.Type,
                Preference      = availability.Preference,
                PushEmailSend   = availability.PushEmailSend,
                LastEditDate    = availability.LastEditDate,
                LastEditBy      = availability.LastEditBy,
                RowVersion      = availability.RowVersion
            };

            if (availability.Participation != null)
            {
                vm.Participation = ParticipationViewModel.CreateVm(availability.Participation);
            }
            if (availability.Shift != null)
            {
                vm.Shift = ShiftViewModel.CreateVm(availability.Shift);
            }
            return(vm);
        }
Пример #4
0
        /// <summary>
        /// Creates a ViewModel from a Participation.
        /// </summary>
        public static ParticipationViewModel CreateVm(Participation participation)
        {
            if (participation == null)
            {
                return(null);
            }
            ParticipationViewModel vm = new ParticipationViewModel
            {
                Id = participation.Id,
                MaxWorkingHoursPerWeek = participation.MaxWorkingHoursPerWeek,
                Availabilities         = participation.Availabilities,
                Remark       = participation.Remark,
                Active       = participation.Active,
                LastEditDate = participation.LastEditDate,
                LastEditBy   = participation.LastEditBy,
                RowVersion   = participation.RowVersion
            };

            if (participation.Person != null)
            {
                vm.Person = PersonViewModel.CreateVmFromPerson(participation.Person);
            }
            if (participation.Project != null)
            {
                vm.Project = ProjectDetailsViewModel.CreateVm(participation.Project);
            }
            return(vm);
        }