public IActionResult TalentCreate([FromForm] IFormCollection data) { //Create an object User type object, user Talents talent = new Talents(); object response = null; try { //Start passing the collected data into the new User object. talent.TalentName = data["name"]; talent.Shortname = data["shortName"]; talent.Bio = data["bio"]; talent.Reknown = data["reknown"]; talent.TalentImageURL = ""; if (talent.TalentName == "") { response = new { status = "fail", message = "Talent Name is required" }; return(BadRequest(response)); } else if (talent.Shortname == "") { response = new { status = "fail", message = "Short Name is required" }; return(BadRequest(response)); } else if (talent.Bio == "") { response = new { status = "fail", message = "Bio is required" }; return(BadRequest(response)); } else if (talent.Reknown == "") { response = new { status = "fail", message = "Reknown is required" }; return(BadRequest(response)); } else { _database.Talents.Add(talent); _database.SaveChanges(); } } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } //Send back an OK with 200 status code return(Ok(new { message = "Successfully Created Talent" })); }//End of post web api
public ActionResult Subscribe(int id) { var user = _database.Users.Where(u => u.Id == id).FirstOrDefault(); try { // Use Stripe's library to make request StripeConfiguration.ApiKey = key; StripeConfiguration.MaxNetworkRetries = 2; var options = new SubscriptionCreateOptions { Customer = customerId, Items = new List <SubscriptionItemOptions> { new SubscriptionItemOptions { Price = productPrice1, }, }, }; var service = new SubscriptionService(); Subscription subscription = service.Create(options); var model = new SubscriptionViewModel(); model.SubscriptionId = subscription.Id; user.CustomerId = subscription.CustomerId; user.RoleId = 2; _putItem.AddNewEntry(subscription.Id, subscription.LatestInvoiceId, user.Id); _database.Users.Update(user); _database.SaveChanges(); return(View("OrderStatus")); } catch (StripeException e) { var x = new { status = "Failed", message = e.Message }; return(this.Json(x)); } }