public IActionResult Settings() { var user_id = _userManager.GetUserId(HttpContext.User); var profile = _profileService.GetProfileByUserId(user_id); ViewBag.children = _childrenService.Get().Where(e => e.profile_id == profile.id); var profile_bank = _profileBankService.GetProfileBank(profile.id); if (profile_bank == null) { profile_bank = new mp_profile_bank(); } ViewBag.bank = profile_bank; var profile_hmo = _profileHMOService.GetProfileHMO(profile.id); if (profile_hmo == null) { profile_hmo = new mp_profile_hmo(); } ViewBag.profile_hmo = profile_hmo; return(View()); }
public IActionResult GetBank(Guid profile_id) { var profile_bank = _profileBankService.Get().FirstOrDefault(e => e.profile_id == profile_id); if (profile_bank == null) { profile_bank = new mp_profile_bank(); } return(Ok(profile_bank)); }
public IActionResult UpdateBank(mp_profile_bank bank) { var user_id = _userManager.GetUserId(HttpContext.User); var profile = _profileService.GetProfileByUserId(user_id); bank.updated_by = user_id.ToString(); bank.created_by = user_id.ToString(); bank.profile_id = profile.id; _profileBankService.AddOrUpdate(bank); return(Redirect(Request.Headers["Referer"].ToString())); }
public ActionResult Cancel(Guid id) { var appointment = _appointmentService.Get().Include(e => e.client_).Include(e => e.clinician_).Include(e => e.mp_credit).FirstOrDefault(e => e.id == id); if (User.IsInRole("client")) { Guid logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User)); mp_profile user_profile = _profileService.GetByUserId(logged_user_id); //check if the user currently has a bank information var profile_bank = _profileBankService.GetProfileBank(user_profile.id); if (profile_bank == null) { profile_bank = new mp_profile_bank(); } ViewBag.bank = profile_bank; } return(View(appointment)); }
public void AddOrUpdate(mp_profile_bank bank) { var old = _context.mp_profile_bank.FirstOrDefault(e => e.id == bank.id); if (old != null) { bank.created_at = old.created_at; bank.created_by = old.created_by; bank.updated_at = DateTime.Now; _context.Entry(old).CurrentValues.SetValues(bank); } else { bank.created_at = DateTime.Now; _context.mp_profile_bank.Add(bank); } _context.SaveChanges(); }
public async Task CancelBySystem(string appointmentid) { Guid logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User)); var cancelReason = string.Empty; var appointment_id = Guid.Parse(appointmentid); var appointment = _appointmentService.Get().Include(e => e.mp_credit) .Include(e => e.client_).Include(e => e.clinician_).FirstOrDefault(e => e.id == appointment_id); if (appointment.status == 234) { var user_notification = "An appointment that you created was cancelled."; var cancelled_by = 298; var profile = _profileService.GetByUserId(logged_user_id); Guid?cancelById = null; if (User.IsInRole("client")) { var user_profile = _profileService.GetByUserId(logged_user_id); var bank = _profileBankService.GetProfileBank(user_profile.id); if (bank == null) { bank = new mp_profile_bank(); } cancelled_by = 297; bank.updated_by = logged_user_id.ToString(); bank.created_by = logged_user_id.ToString(); bank.profile_id = profile.id; cancelById = appointment.client_id; _profileBankService.AddOrUpdate(bank); cancelReason = "Clinician not avilable on time."; } if (User.IsInRole("clinician")) { cancelById = appointment.clinician_id; cancelReason = "Client not avilable on time."; } //check if payment has been made for the appointment if (appointment.mp_credit.Any() && appointment.status != 171 && User.IsInRole("clinician")) { var creditInfo = appointment.mp_credit.FirstOrDefault(x => x.appointment_id == appointment.id); if (creditInfo != null) { var resundResponse = new PayStackHelper(_payStackSettings).Refund(creditInfo.transaction_reference); if (resundResponse) { user_notification += " Your payment will be processed shortly and you will get it back in the next 24 - 48 hours."; //refund the client var refund = new mp_appointment_refund { appointment_id = appointment_id, created_by = logged_user_id.ToString(), amount = appointment.mp_credit.FirstOrDefault().amount, cancelled_by = cancelled_by, status = 296 }; _appointmentRefundService.AddRefund(refund); } } } appointment.status = 171; appointment.cancelled_by = cancelById; appointment.cancel_reason = cancelReason; _appointmentService.Update(appointment); //notifications to the client and the clinician var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.client_.user_id, notification = "Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification + ", due to " + cancelReason, title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.client_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification + ", due to " + cancelReason); notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.clinician_.user_id, notification = "Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled." + ", due to " + cancelReason, title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.clinician_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled" + ", due to " + cancelReason); } }
public async Task <IActionResult> Cancel(mp_profile_bank bank) { var collection = Request.Form; var appointment_id = Guid.Parse(collection["appointment_id"]); var appointment = _appointmentService.Get().Include(e => e.mp_credit).Include(e => e.client_).Include(e => e.clinician_).FirstOrDefault(e => e.id == appointment_id); if (appointment.status != 169 && appointment.status != 234) { TempData["AlertType"] = "alert-warning"; TempData["AlertMessage"] = "This appointment cannot be cancelled."; return(RedirectToAction("Details", new { id = appointment_id })); } var user_notification = "An appointment that you created was cancelled."; Guid logged_user_id = Guid.Parse(_userManager.GetUserId(HttpContext.User)); var cancelled_by = 298; var profile = _profileService.GetByUserId(logged_user_id); Guid?cancelById = null; if (User.IsInRole("client")) { cancelled_by = 297; bank.updated_by = logged_user_id.ToString(); bank.created_by = logged_user_id.ToString(); bank.profile_id = profile.id; cancelById = appointment.client_id; _profileBankService.AddOrUpdate(bank); } if (User.IsInRole("clinician")) { cancelById = appointment.clinician_id; } //check if payment has been made for the appointment if (appointment.mp_credit.Any() && appointment.status != 171) { var creditInfo = appointment.mp_credit.FirstOrDefault(x => x.appointment_id == appointment.id); if (creditInfo != null) { var resundResponse = new PayStackHelper(_payStackSettings).Refund(creditInfo.transaction_reference); if (resundResponse) { user_notification += " Your payment will be processed shortly and you will get it back in the next 24 - 48 hours."; //refund the client var refund = new mp_appointment_refund { appointment_id = appointment_id, created_by = logged_user_id.ToString(), amount = appointment.mp_credit.FirstOrDefault().amount, cancelled_by = cancelled_by, status = 296 }; _appointmentRefundService.AddRefund(refund); } } } appointment.status = 171; appointment.cancelled_by = cancelById; appointment.cancel_reason = collection["comment"]; _appointmentService.Update(appointment); //notifications to the client and the clinician var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.client_.user_id, notification = "Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification, title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.client_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.client_.last_name + " " + appointment.client_.first_name + ", " + user_notification); notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 5, read = 0, user_id = appointment.clinician_.user_id, notification = "Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled.", title = "Appointment cancelled" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(appointment.clinician_.email, "Appointment cancelled - MySpace MyTime", $"Hi " + appointment.clinician_.last_name + " " + appointment.clinician_.first_name + ", an appointment scheduled with you have been cancelled."); return(RedirectToAction("CancelConfirmation")); }
public IActionResult PostBank(mp_profile_bank bank) { _profileBankService.AddOrUpdate(bank); return(Ok(200)); }