Exemple #1
0
        internal static async Task <tblCandidateSubmissionAppointment> saveAppointment(this AppointmentManager appointment, tblCandidateSubmissionAppointment data)
        {
            try
            {
                appointment.db.tblCandidateSubmissionAppointments.Add(data);
                await appointment.db.SaveChangesAsync();

                return(data);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task <CandidateSubmissionAppointmentViewModel> Save(CandidateSubmissionAppointmentViewModel data)
        {
            try
            {
                var objAppointment = new tblCandidateSubmissionAppointment()
                {
                    AppintmentTypeID    = data.AppintmentTypeID,
                    AppointmentStatusID = data.AppointmentStatusID,
                    Name                  = data.Name,
                    Details               = data.Details,
                    IsActive              = data.isActive,
                    IsDeleted             = data.isDeleted,
                    CreatedUserID         = data.createdUserID,
                    CreatedTimestamp      = DateTime.UtcNow,
                    CandidateSubmissionID = data.CandidateSubmissionID,
                    tblCandidateSubmissionAppointmentSlots = data.Slots.Select(x => new tblCandidateSubmissionAppointmentSlot()
                    {
                        StartDate        = x.StartDate,
                        EndDate          = x.EndDate,
                        IsActive         = x.isActive,
                        IsDeleted        = x.isDeleted,
                        CreatedUserID    = data.createdUserID,
                        CreatedTimestamp = DateTime.UtcNow,
                        IsFinalised      = x.IsFinalised
                    }).ToList(),
                    tblCandidateSubmissionAppointmentUsers = data.Users.Select(x => new tblCandidateSubmissionAppointmentUser()
                    {
                        UserID           = x.UserID,
                        IsActive         = x.isActive,
                        IsDeleted        = x.isDeleted,
                        CreatedTimestamp = DateTime.UtcNow,
                        CreatedUserID    = data.createdUserID
                    }).ToList()
                };

                var appointment = await this.saveAppointment(objAppointment);

                return(new CandidateSubmissionAppointmentViewModel()
                {
                    ID = appointment.ID,
                    AppintmentTypeID = appointment.AppintmentTypeID,
                    AppointmentStatusID = appointment.AppointmentStatusID,
                    CandidateSubmissionID = appointment.CandidateSubmissionID,
                    Name = appointment.Name,
                    Details = appointment.Details,
                    isActive = appointment.IsActive,
                    createdTimestamp = appointment.CreatedTimestamp,
                    //Status = new AppointmentStatusViewModel()
                    //{
                    //    ID = appointment.tblAppointmentStatu != null ? appointment.tblAppointmentStatu.ID : null,
                    //    Name = appointment.tblAppointmentStatu.Name
                    //},
                    //Type = new AppointmentTypeViewModel()
                    //{
                    //    ID = appointment.tblAppointmentType.ID,
                    //    Name = appointment.tblAppointmentType.Name
                    //},
                    Slots = appointment.tblCandidateSubmissionAppointmentSlots.Select(x => new CandidateSubmissionAppointmentSlotViewModel()
                    {
                        ID = x.ID,
                        AppintmentID = x.AppintmentID,
                        StartDate = x.StartDate,
                        EndDate = x.EndDate,
                        isActive = x.IsActive,
                        IsFinalised = x.IsFinalised
                    }).ToList(),
                    Users = appointment.tblCandidateSubmissionAppointmentUsers.Select(x => new CandidateSubmissionAppointmentUserViewModel()
                    {
                        ID = x.ID,
                        AppointmentID = x.AppointmentID,
                        UserID = x.UserID,
                        isActive = x.IsActive,
                        isDeleted = x.IsDeleted
                    }).ToList()
                });
            }
            catch (Exception)
            {
                throw;
            }
        }
 public static CandidateSubmissionAppointment ConvertToCandidateSubmissionAppointment(this tblCandidateSubmissionAppointment data)
 {
     return(new CandidateSubmissionAppointment()
     {
         id = data.ID,
         appintmentTypeID = data.AppintmentTypeID,
         candidateSubmissionID = data.CandidateSubmissionID,
         appointmentStatusID = data.AppointmentStatusID,
         name = data.Name,
         details = data.Details,
         isActive = data.IsActive,
         isDeleted = data.IsDeleted,
         createdUserID = data.CreatedUserID,
         updatedUserID = data.UpdatedUserID,
         createdTimestamp = data.CreatedTimestamp,
         updatedTimestamp = data.UpdatedTimestamp
     });
 }