public async Task <IActionResult> Payment(int id) { var user = await GetCurrentUserAsync(); var donation = _donationService.GetById(id); var detail = (DonationViewModel)donation; detail.DonationOptions = _donationService.DonationOptions; var model = new CustomerPaymentViewModel { Name = user.FullName, AddressLine1 = user.AddressLine1, AddressLine2 = user.AddressLine2, City = user.City, State = user.State, Country = user.Country, Zip = user.Zip, DonationId = donation.Id, Description = detail.GetDescription(), Frequency = detail.GetCycle(), Amount = detail.GetDisplayAmount() }; return(View(model)); }
//PUT /api/wishes/5 public IHttpActionResult Put(Donation donation) { if (ModelState.IsValid) { //get the wish to update var DonationToUpdate = service.GetById(donation.ID); //add the updated attributes DonationToUpdate.Date = DateTime.Now; DonationToUpdate.Sum = donation.Sum; service.Update(DonationToUpdate); service.Commit(); //update the wish Wish wish = wishService.GetById(donation.WishId); wish.FundRaised -= DonationToUpdate.Sum; wish.FundRaised += donation.Sum; wishService.Update(wish); wishService.Commit(); return(Ok()); } return(NotFound()); }
public async Task <IActionResult> Payment(int id) { var user = await GetCurrentUserAsync(); try { var donation = _donationService.GetById(id); var detail = (DonationViewModel)donation; List <CountryViewModel> countryList = GetCountryList(); // Check for existing customer // edit = 1 means user wants to edit the credit card information if (!string.IsNullOrEmpty(user.StripeCustomerId)) { try { var CustomerService = new StripeCustomerService(_stripeSettings.Value.SecretKey); StripeCustomer objStripeCustomer = CustomerService.Get(user.StripeCustomerId); StripeCard objStripeCard = null; if (objStripeCustomer.Sources != null && objStripeCustomer.Sources.TotalCount > 0 && objStripeCustomer.Sources.Data.Any()) { objStripeCard = objStripeCustomer.Sources.Data.FirstOrDefault().Card; } if (objStripeCard != null && !string.IsNullOrEmpty(objStripeCard.Id)) { CustomerRePaymentViewModel customerRePaymentViewModel = CustomerRepaymentModelData(user, donation, detail, countryList, objStripeCustomer, objStripeCard); return(View("RePayment", customerRePaymentViewModel)); } } catch (StripeException ex) { log = new EventLog() { EventId = (int)LoggingEvents.GET_ITEM, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source, EmailId = user.Email }; _loggerService.SaveEventLogAsync(log); ModelState.AddModelError("CustomerNotFound", ex.Message); } } CustomerPaymentViewModel customerPaymentViewModel = GetCustomerPaymentModel(user, donation, detail, countryList); return(View("Payment", customerPaymentViewModel)); } catch (Exception ex) { log = new EventLog() { EventId = (int)LoggingEvents.GET_ITEM, LogLevel = LogLevel.Error.ToString(), Message = ex.Message, StackTrace = ex.StackTrace, Source = ex.Source, EmailId = user.Email }; _loggerService.SaveEventLogAsync(log); return(RedirectToAction("Error", "Error500", new ErrorViewModel() { Error = ex.Message })); } }
public HttpResponseMessage GetById(HttpRequestMessage request, int id) { return(CreateHttpResponse(request, () => { var model = _donationService.GetById(id); var responseData = Mapper.Map <Donation, DonationViewModel>(model); var response = request.CreateResponse(HttpStatusCode.OK, responseData); return response; })); }
public async Task <ActionResult <DonationDTO> > GetDonation(int id, bool includeDeleted) { var donation = await donationService.GetById(id, includeDeleted); if (donation == null) { return(NotFound()); } return(Ok(donation)); }
public ActionResult DonationDetails(int id) { try { var result = _donationService.GetById(id); if (result.HasError) { ViewBag.Message = result.Message; return(Content(result.Message)); } return(Content(result.Message)); } catch (Exception e) { return(Content(e.Message)); } }