public APS.BusinessEntity.Models.Appointment.AppointmentModel GetAppointmentDetails(string UserName) { APSEntities dbContext = new APSEntities(); UserInfoModel userInfo = new UserInfoModel(); userInfo.UserName = UserName; using (AuthenticationRepository authRepo = new AuthenticationRepository()) { userInfo = authRepo.GetUserInfoDetails(userInfo); } var appointments = dbContext.V_APPOINTMENT_DETAILS.Where(i => i.APP_USERNAME == UserName).FirstOrDefault(); if (appointments != null) { var model = appointments.ToAppointmentModel(); model.UserInfoDetails = userInfo; return(model); } else { APS.BusinessEntity.Models.Appointment.AppointmentModel model = new APS.BusinessEntity.Models.Appointment.AppointmentModel(); model.IsAppointmentAvailable = false; model.UserInfoDetails = userInfo; return(model); } }
public void SendEmailOnBookOrChangeAppointment(APS.BusinessEntity.Models.Appointment.AppointmentModel appointModel) { Log.Error("call BookOrChangeAppointment BC"); SendEmailRequest emailRequest = new SendEmailRequest(); UserInfoModel userModel = new UserInfoModel(); userModel.UserName = appointModel.App_UserName; using (AuthenticationRepository authRepo = new AuthenticationRepository()) { userModel = authRepo.GetUserInfoDetails(userModel); } BuildAndSendEmailRequest(emailRequest, userModel.UserEmail, "APS - Book/Change Appointment", "Your appointment has booked. Next appointment will be: " + appointModel.App_Date + " On " + appointModel.App_TimeSlot_Description); }
public APS.BusinessEntity.Models.Appointment.AppointmentModel BookOrChangeAppointment(APS.BusinessEntity.Models.Appointment.AppointmentModel appModel) { try { Log.Error("call BookOrChangeAppointment BC"); APS.BusinessEntity.Models.Appointment.AppointmentModel appointModel = new APS.BusinessEntity.Models.Appointment.AppointmentModel(); using (AppointmentBookingRepository repo = new AppointmentBookingRepository()) { appointModel = repo.BookOrChangeAppointment(appModel); if (appointModel.App_Change_Count < 4) { SendEmailOnBookOrChangeAppointment(appointModel); } } return(appointModel); } catch (Exception ex) { throw ex; } }
public APS.BusinessEntity.Models.Appointment.AppointmentModel BookOrChangeAppointment(APS.BusinessEntity.Models.Appointment.AppointmentModel appModel) { try { UserInfoModel userInfo = new UserInfoModel(); userInfo.UserName = appModel.App_UserName; using (AuthenticationRepository authRepo = new AuthenticationRepository()) { userInfo = authRepo.GetUserInfoDetails(userInfo); } APS.BusinessEntity.Models.Appointment.AppointmentModel appointModel = new APS.BusinessEntity.Models.Appointment.AppointmentModel(); APSEntities dbContext = new APSEntities(); DateTime appDt; DateTime.TryParse(appModel.App_Date, out appDt); if (!appModel.IsAppointmentAvailable) { var objApp = new APS_APPOINTMENT { APP_DATE = appDt, APP_TIMESLOT_ID = appModel.App_TimeSlot_ID, APP_USERNAME = appModel.App_UserName, CREATED_BY = appModel.App_UserName, CREATED_ON = DateTime.Now, LAST_UPDATED_BY = appModel.App_UserName, LAST_UPDATED_ON = DateTime.Now, APP_STATUS = BusinessConstants.AppointmetStatus.Active, APP_CHANGE_CNT = 0 }; dbContext.APS_APPOINTMENT.Add(objApp); dbContext.SaveChanges(); appModel.App_ID = objApp.APP_ID; } else { var selectedEntity = dbContext.APS_APPOINTMENT.FirstOrDefault(p => p.APP_ID == appModel.App_ID); if (appModel.App_Change_Count <= 3) { selectedEntity.APP_CHANGE_CNT = appModel.App_Change_Count; selectedEntity.APP_TIMESLOT_ID = appModel.App_TimeSlot_ID; selectedEntity.LAST_UPDATED_BY = appModel.App_UserName; selectedEntity.LAST_UPDATED_ON = DateTime.Now; } else if (appModel.App_Change_Count > 3) { selectedEntity.APP_CHANGE_CNT = appModel.App_Change_Count; selectedEntity.LAST_UPDATED_BY = appModel.App_UserName; selectedEntity.LAST_UPDATED_ON = DateTime.Now; } dbContext.Entry(selectedEntity).State = EntityState.Modified; dbContext.SaveChanges(); } var appointments = dbContext.V_APPOINTMENT_DETAILS.Where(i => i.APP_USERNAME == appModel.App_UserName).FirstOrDefault(); if (appointments != null) { appointModel = appointments.ToAppointmentModel(); } appointModel.UserInfoDetails = userInfo; return(appointModel); } catch (Exception ex) { throw ex; } }