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 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)); }