// POST api/credit public IHttpActionResult Post([FromBody] CreditBindingModel creditModel) { try { var credit = Mapper.Map <DomainCredit>(creditModel); creditService.Add(credit); return(Ok()); } catch (BankClientException ex) { return(BadRequest(ex.Message)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IActionResult> PostCredit(mp_credit credit) { // var email = _userManager.GetUserId(HttpContext.User); // var user = await _userManager.FindByEmailAsync(email); credit.created_by = "self"; //user.Id; try { _creditService.Add(credit); } catch (Exception ex) { return(Ok(500)); } return(Ok(200)); }
public IActionResult PostCredit(mp_credit credit) { var user_id = _userManager.GetUserId(HttpContext.User); var profile = _profileService.GetProfileByUserId(user_id); credit.profile_id = profile.id; try { _creditService.Add(credit); } catch (Exception ex) { _logger.LogError("Error crediting an account", ex); return(Ok(500)); } return(Ok(200)); }
public async Task <ActionResult> ConfirmAppointment(IFormCollection collection) { var user_id = _userManager.GetUserId(HttpContext.User); var appointment_id = collection["appointment_id"]; try { mp_appointment appointment = _appointmentService.Get().Include(x => x.client_).Include(x => x.clinician_).FirstOrDefault(e => e.id == Guid.Parse(appointment_id)); mp_credit credit = new mp_credit { amount = Convert.ToDecimal(collection["amount"]), profile_id = appointment.client_id, created_by = user_id, appointment_id = appointment.id, mode_of_payment = 1, transaction_reference = collection["transaction_reference"] }; _creditService.Add(credit); appointment.status = 234; _appointmentService.Update(appointment); var admins = await _userManager.GetUsersInRoleAsync("super_admin"); await new NotificationHelper(_emailSender).AppointmentScheduled(appointment, admins); TempData["AlertType"] = "alert-success"; TempData["AlertMessage"] = "Successfully booked an appointment"; return(RedirectToAction("CompletedBooking", "Appointment")); } catch (Exception ex) { TempData["AlertType"] = "alert-warning"; TempData["AlertMessage"] = "Payment for appointment was not successful, Kindly select the appoinment and go to payment"; return(RedirectToAction("ConfirmAppointment", "Appointment", new { id = appointment_id })); } }