public void Log() { var log = new EventureLog(); log.Message = "starting payment"; log.Caller = "StripePayment"; log.Status = "Info"; log.LogDate = System.DateTime.Now.ToLocalTime(); log.DateCreated = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(log); db.SaveChanges(); }
public HttpResponseMessage CreateOrder(JObject orderBundle) { //TransactionStatus transactionStatus; // var results = new StudentValidation().Validate(studentViewModel); //if (!results.IsValid) //{ // studentViewModel.Errors = GenerateErrorMessage.Built(results.Errors); // studentViewModel.ErrorType = ErrorTypeEnum.Error.ToString().ToLower(); // studentViewModel.Status = false; // var badResponse = Request.CreateResponse(HttpStatusCode.BadRequest, studentViewModel); // return badResponse; //} //var stundentBo = BuiltStudentBo(studentViewModel); //stundentBo.PaymentMethods = string.Join(",", studentViewModel.SelectedPaymentMethods); //stundentBo.Gender = studentViewModel.SelectedGender; //transactionStatus = _studentService.CreateStudent(stundentBo); int place = 0; try { //quick val check required? //deserial obj var order = BuildOrder(orderBundle); //validate //capacity and such //calculate fees place = 1; Owner owner = db.Owners.Where(o => o.Id == 1).SingleOrDefault(); if (owner == null) { throw new Exception("Owner Setup is Not Configured Correctly"); } //var custDesc = string.Empty; //var partEmail = string.Empty; //var partName = string.Empty; var part = db.Participants.Where(p => p.Id == order.HouseId).FirstOrDefault(); if (part != null) { //custDesc = part.FirstName + " " + part.LastName + "_ord" + order.Id; //partEmail = part.Email; //partName = part.FirstName + " " + part.LastName; } else { throw new Exception("couldn't find that houseId"); } place = 2; //calulate order.CardProcessorFeeInCents = Convert.ToInt32(Math.Round(Convert.ToInt32(order.Amount * 100) * owner.CardProcessorFeePercentPerCharge / 100, 0) + owner.CardProcessorFeeFlatPerChargeInCents); order.LocalFeeInCents = Convert.ToInt32(Math.Round(Convert.ToInt32(order.Amount * 100) * owner.LocalFeePercentOfCharge / 100, 0) + owner.LocalFeeFlatPerChargeInCents); order.LocalApplicationFee = order.LocalFeeInCents - order.CardProcessorFeeInCents; if (order.LocalApplicationFee < 0) { order.LocalApplicationFee = 0; } //} //create stripe service,customer, charge //charge card //var stripeService = new Stripe. //if good //record charege //create order //StripeService stripeService = new StripeService(); //tring customerEmail,string customerDescription, string customerToken, string accessToken, string chargeDescription, decimal chargeAmount, Int32 applicationFee //var stripeCharge = stripeService.CreateCharge(part.Email, part.FirstName + " " + part.LastName, order.Token, owner.AccessToken, owner.Name, order.Amount, order.LocalApplicationFee); // public StripeCharge CreateCharge(string customerEmail,string customerDescription, string customerToken, string accessToken, string chargeDescription, decimal chargeAmount, Int32 applicationFee ) //{ place = 3; var customerOptions = new StripeCustomerCreateOptions { Email = part.Email, //Email, Description = part.FirstName + " " + part.LastName, TokenId = order.Token, }; var stripeCustomerService = new StripeCustomerService(owner.AccessToken); //owner.AccessToken var customer = stripeCustomerService.Create(customerOptions); place = 4; //int err = place / (place - place); var stripeChargeService = new StripeChargeService(owner.AccessToken); //The token returned from the above method var stripeChargeOption = new StripeChargeCreateOptions() { Amount = Convert.ToInt32(order.Amount * 100), Currency = "usd", CustomerId = customer.Id, Description = owner.Name, ApplicationFee = order.LocalApplicationFee }; place = 5; var stripeCharge = stripeChargeService.Create(stripeChargeOption); place = 6; if (string.IsNullOrEmpty(stripeCharge.FailureCode)) { //orderService.CompleteOrder(stripeCharge) order.AuthorizationCode = stripeCharge.Id; //stripeCharge. order.CardNumber = stripeCharge.StripeCard.Last4; order.CardCvcCheck = stripeCharge.StripeCard.CvcCheck; order.CardExpires = stripeCharge.StripeCard.ExpirationMonth + "/" + stripeCharge.StripeCard.ExpirationYear; order.CardFingerprint = stripeCharge.StripeCard.Fingerprint; //order.CardId = stripeCharge.StripeCard.; order.CardName = stripeCharge.StripeCard.Name; order.CardOrigin = stripeCharge.StripeCard.Country; //mjb fixorder.CardType = stripeCharge.StripeCard.Type; order.Voided = false; order.Status = "Complete"; order.OrderStatus = OrderStatus.Completed; //mjb fix order.PaymentType = "credit"; //db.Orders.Add(order); //db.SaveChanges(); place = 7; //not good return reason OrderService _orderService = new OrderService(); var x = _orderService.CreateOrder(order); place = 8; HttpResponseMessage result; if (ConfigurationManager.AppSettings["CustomName"] == "bourbonchase") { //result = new MailController().SendBourbonLotteryConfirm(order.Id); result = new MailController().SendConfirmMail(order.Id); //change back to bourbon chase?? } else { result = new MailController().SendConfirmMail(order.Id); } //HttpResponseMessage result = new MailController().SendTestEmail(); var resp = Request.CreateResponse(HttpStatusCode.OK); //resp.Content = new StringContent(); resp.Content = new StringContent(order.Id.ToString(), Encoding.UTF8, "text/plain"); return(resp); } else { //order.Status = stripeCharge.FailureMessage; //db.SaveChanges(); //return //var badResponse = Request.CreateResponse(HttpStatusCode.ExpectationFailed, stripeCharge); //stripeCharge.FailureCode //return badResponse; var logE = new EventureLog(); logE.Message = "Stripe Exception: " + stripeCharge.FailureMessage + " -- place: " + place + " -- bundle: " + orderBundle; logE.Caller = "Order_ERROR_stripe"; logE.Status = "Warning"; logE.LogDate = System.DateTime.Now.ToLocalTime(); logE.DateCreated = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(logE); db.SaveChanges(); var badResp = Request.CreateResponse(HttpStatusCode.BadRequest); badResp.Content = new StringContent(stripeCharge.FailureMessage, Encoding.UTF8, "text/plain"); return(badResp); } } catch (Exception ex) { var logE = new EventureLog(); logE.Message = "Order exception: " + ex.Message + " -- place: " + place + " -- bundle: " + orderBundle; logE.Caller = "Order_ERROR"; logE.Status = "ERROR"; logE.LogDate = System.DateTime.Now.ToLocalTime(); logE.DateCreated = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(logE); db.SaveChanges(); //var x = "there was an issue"; //var badResponse = Request.CreateResponse(HttpStatusCode.BadRequest, x.ToString()); //return badResponse; string message = ex.Message; string returnMessage = string.Empty; if (message.Substring(0, 4) == "Your") { returnMessage = ex.Message; } else { returnMessage = "There was problem processing your order. Please Try again."; } var badResp = Request.CreateResponse(HttpStatusCode.BadRequest); //resp.Content = new StringContent(); badResp.Content = new StringContent(returnMessage, Encoding.UTF8, "text/plain"); return(badResp); } //if (transactionStatus.Status == false) //{ // var badResponse = Request.CreateResponse(HttpStatusCode.BadRequest, JsonConvert.SerializeObject(studentViewModel)); // return badResponse; //} //else //{ // transactionStatus.ErrorType = ErrorTypeEnum.Success.ToString(); // transactionStatus.ReturnMessage.Add("Record successfully inserted to database"); // var badResponse = Request.CreateResponse(HttpStatusCode.Created, transactionStatus); // return badResponse; //} }
public HttpResponseMessage CreateZeroAmountOrder(JObject orderBundle) { int place = 0; try { //deserial obj var order = BuildOrder(orderBundle); //validate //capacity and such //calculate fees place = 1; Owner owner = db.Owners.Where(o => o.Id == 1).SingleOrDefault(); if (owner == null) { throw new Exception("Owner Setup is Not Configured Correctly"); } var part = db.Participants.Where(p => p.Id == order.HouseId).FirstOrDefault(); if (part != null) { //custDesc = part.FirstName + " " + part.LastName + "_ord" + order.Id; //partEmail = part.Email; //partName = part.FirstName + " " + part.LastName; } else { throw new Exception("couldn't find that houseId"); } place = 2; ////orderService.CompleteOrder(stripeCharge) //order.AuthorizationCode = stripeCharge.Id; ////stripeCharge. //order.CardNumber = stripeCharge.StripeCard.Last4; //order.CardCvcCheck = stripeCharge.StripeCard.CvcCheck; //order.CardExpires = stripeCharge.StripeCard.ExpirationMonth + "/" + stripeCharge.StripeCard.ExpirationYear; //order.CardFingerprint = stripeCharge.StripeCard.Fingerprint; ////order.CardId = stripeCharge.StripeCard.; //order.CardName = stripeCharge.StripeCard.Name; //order.CardOrigin = stripeCharge.StripeCard.Country; //mjb fixorder.CardType = stripeCharge.StripeCard.Type; order.Voided = false; order.Status = "Complete"; //mjb fix order.PaymentType = "credit"; //db.Orders.Add(order); //db.SaveChanges(); place = 7; //not good return reason OrderService _orderService = new OrderService(); var x = _orderService.CreateOrder(order); place = 8; HttpResponseMessage result; //if (ConfigurationManager.AppSettings["CustomName"] == "bourbonchase") // result = new MailController().SendBourbonLotteryConfirm(order.Id); //else result = new MailController().SendConfirmMail(order.Id); //HttpResponseMessage result = new MailController().SendTestEmail(); var resp = Request.CreateResponse(HttpStatusCode.OK); //resp.Content = new StringContent(); resp.Content = new StringContent(order.Id.ToString(), Encoding.UTF8, "text/plain"); return(resp); } catch (Exception ex) { var logE = new EventureLog(); logE.Message = "Order exception: " + ex.Message + " -- place: " + place + " -- bundle: " + orderBundle; logE.Caller = "OrderZERo_ERROR"; logE.Status = "ERROR"; logE.LogDate = System.DateTime.Now.ToLocalTime(); logE.DateCreated = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(logE); db.SaveChanges(); var badResp = Request.CreateResponse(HttpStatusCode.BadRequest); //resp.Content = new StringContent(); badResp.Content = new StringContent("There was a problem with your order. Please try again", Encoding.UTF8, "text/plain"); return(badResp); } }
public HttpResponseMessage StripeResponse() //Int32 OwnerId { try { var log = new EventureLog(); log.Message = "So far so good"; log.Caller = "StripeResponse"; log.Status = "Info"; log.LogDate = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(log); db.SaveChanges(); var queryValue = Request.RequestUri.ParseQueryString(); if (queryValue["error_description"] != null) { var logE = new EventureLog(); logE.Message = "Error Stripe Call 1: " + queryValue["error_description"]; logE.Caller = "StripeResponse_ERROR"; logE.Status = "ERROR"; logE.LogDate = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(logE); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } string code = queryValue["code"]; log.Message = "got the code: " + code; log.Caller = "StripeResponse"; log.Status = "Info"; log.LogDate = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(log); db.SaveChanges(); var stripeService = new StripeOAuthTokenService(ConfigurationManager.AppSettings["StripeSecret"]); var stripeTokenOptions = new StripeOAuthTokenCreateOptions() { Code = code, GrantType = "authorization_code" }; var response = stripeService.Create(stripeTokenOptions); log.Caller = "StripeResponse"; log.Status = "Info"; log.LogDate = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(log); db.SaveChanges(); if (response.Error != null) { var logE = new EventureLog(); logE.Message = "Error Stripe Call 2: " + response.ErrorDescription; logE.Caller = "StripeResponse_ERROR"; logE.Status = "ERROR"; logE.LogDate = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(logE); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.PaymentRequired)); } var OwnerId = 1; //need to pass this in from profile mjb var owner = db.Owners.FirstOrDefault(o => o.Id == OwnerId); owner.AccessToken = response.AccessToken; owner.RefreshToken = response.RefreshToken; owner.StripePublishableKey = response.PublishableKey; owner.StripeUserId = response.StripeUserId; owner.Livemode = response.LiveMode; owner.Scope = response.Scope; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); //var resp = Request.CreateResponse(HttpStatusCode.Moved); //would be cool to call owner again to show changes; might be easier for javascript //resp.Headers.Location = new Uri("http://www.google.com"); //return resp; } catch (Exception ex) { var logE = new EventureLog(); logE.Message = "Error Handler: " + ex.Message; logE.Caller = "StripeResponse_ERROR"; logE.Status = "ERROR"; logE.LogDate = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(logE); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage Transfer(JObject saveBundle) { try { //int numOfRegs = 0; //decimal totalFees = 0; var transferId = (Int32)saveBundle["transferId"]; var transferNewListName = (string)saveBundle["transferNewListName"]; var participantId = (Int32)saveBundle["partId"]; var log = new EventureLog(); log.Message = "starting transfer: " + transferId; log.Caller = "transfer"; log.Status = "Info"; log.LogDate = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(log); db.SaveChanges(); var transfer = db.EventureTransfers.Where(t => t.Id == transferId).Single(); var order = new EventureOrder { DateCreated = DateTime.Now, //HouseId = (Int32)saveBundle["houseId"], Amount = (Decimal)saveBundle["amount"], Token = (string)saveBundle["token"], //is this safe?? OwnerId = (Int32)saveBundle["ownerId"], Status = "init transfer", Voided = false }; db.Orders.Add(order); Owner owner = db.Owners.Where(o => o.Id == order.OwnerId).SingleOrDefault(); if (owner == null) { throw new Exception("Owner Setup is Not Configured Correctly"); } //validate //must have transferId, //i could process without partId just no email //calulate order.CardProcessorFeeInCents = Convert.ToInt32(Math.Round(Convert.ToInt32(order.Amount * 100) * owner.CardProcessorFeePercentPerCharge / 100, 0) + owner.CardProcessorFeeFlatPerChargeInCents); order.LocalFeeInCents = Convert.ToInt32(Math.Round(Convert.ToInt32(order.Amount * 100) * owner.LocalFeePercentOfCharge / 100, 0) + owner.LocalFeeFlatPerPerChargeInCents); order.LocalApplicationFee = order.LocalFeeInCents - order.CardProcessorFeeInCents; string custDesc = string.Empty; string partEmail = string.Empty; var part = db.Participants.Where(p => p.Id == participantId).FirstOrDefault(); if (part != null) { custDesc = "_transfer" + transferId; partEmail = part.Email; } else { //this should never happen throw exception? //NO house Id throw new Exception("There was an issue with submission, Not signed into account."); } // create customer var customerOptions = new StripeCustomerCreateOptions { Email = partEmail, Description = custDesc, TokenId = order.Token, }; var stripeCustomerService = new StripeCustomerService(owner.AccessToken); var customer = stripeCustomerService.Create(customerOptions); var stripeChargeService = new StripeChargeService(owner.AccessToken); //The token returned from the above method var stripeChargeOption = new StripeChargeCreateOptions() { AmountInCents = Convert.ToInt32(order.Amount * 100), Currency = "usd", CustomerId = customer.Id, Description = owner.Name, //this needs to be dynamic ApplicationFeeInCents = order.LocalApplicationFee }; var stripeCharge = stripeChargeService.Create(stripeChargeOption); if (string.IsNullOrEmpty(stripeCharge.FailureCode)) { // update reg var reg = db.Registrations.Where(r => r.Id == transfer.RegistrationId).Single(); reg.EventureListId = transfer.EventureListIdTo; // mjb 060914 reg.Name = transferNewListName; reg.Type = "xferup"; transfer.IsComplete = true; order.AuthorizationCode = stripeCharge.Id; //stripeCharge. order.CardNumber = stripeCharge.StripeCard.Last4; order.CardCvcCheck = stripeCharge.StripeCard.CvcCheck; order.CardExpires = stripeCharge.StripeCard.ExpirationMonth + "/" + stripeCharge.StripeCard.ExpirationYear; order.CardFingerprint = stripeCharge.StripeCard.Fingerprint; //order.CardId = stripeCharge.StripeCard.; order.CardName = stripeCharge.StripeCard.Name; order.CardOrigin = stripeCharge.StripeCard.Country; order.CardType = stripeCharge.StripeCard.Type; order.Voided = false; order.Status = "Complete"; db.SaveChanges(); var resp = Request.CreateResponse(HttpStatusCode.OK); //resp.Content = new StringContent(); resp.Content = new StringContent(transferId.ToString(), Encoding.UTF8, "text/plain"); //send transferId?? just for practice?? return(resp); //var resp = Request.CreateResponse(HttpStatusCode.OK); ////resp.Content = new StringContent(); //resp.Content = new StringContent(order.Id.ToString(), Encoding.UTF8, "text/plain"); //return resp; } else { order.Status = stripeCharge.FailureMessage; db.SaveChanges(); //should i save here? return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, stripeCharge)); } } catch (Exception ex) { //send quick email HttpResponseMessage result = new MailController().SendInfoMessage("*****@*****.**", "Error Handler_Payment_Post: " + ex.Message + "\n\n" + ex.InnerException); //regular log var logE = new EventureLog { Message = "Error Handler: " + ex.Message + "\n\n" + ex.InnerException, Caller = "Payment_Post", Status = "ERROR", LogDate = System.DateTime.Now.ToLocalTime() }; db.EventureLogs.Add(logE); db.SaveChanges(); var returnMessage = "There was error with your transaction, please try again."; if (ex.Source == "Stripe.net") { returnMessage = ex.Message; } if (Request != null) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, returnMessage)); } //return Request.CreateResponse(HttpStatusCode.InternalServerError); else { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); //return new HttpResponseMessage(HttpStatusCode.InternalServerError,); } } }
public HttpResponseMessage AddSchedule(JObject saveBundle) { try { var houseId = (Int32)saveBundle["houseId"]; var eventId = (Int32)saveBundle["eventId"]; var shiftId = (Int32)saveBundle["shiftId"]; var volunteerId = 0; var volunteer = new Volunteer(); //verify all are > 0 var schedule = new VolunteerSchedule(); schedule.EventureId = eventId; schedule.VolunteerShiftId = shiftId; schedule.DateCreated = DateTime.Now; if (db.Volunteers.Any(v => v.ParticipantId == houseId)) { schedule.VolunteerId = db.Volunteers.SingleOrDefault(v => v.ParticipantId == houseId).Id; } else { volunteer.ParticipantId = houseId; volunteer.DateCreated = DateTime.Now; db.Volunteers.Add(volunteer); schedule.VolunteerId = volunteer.Id; } db.VolunteerSchedules.Add(schedule); db.SaveChanges(); //call mail //HttpResponseMessage result = new MailController().SendConfirmMail(order.Id); var resp = Request.CreateResponse(HttpStatusCode.OK); //resp.Content = new StringContent(); resp.Content = new StringContent(schedule.Id.ToString(), Encoding.UTF8, "text/plain"); return(resp); } catch (Exception ex) { //send quick email HttpResponseMessage result = new MailController().SendInfoMessage("*****@*****.**", "Error Handler_AddSchedule: " + ex.Message + "\n\n" + ex.InnerException); //regular log var logE = new EventureLog { Message = "Error Handler: " + ex.Message + "\n\n" + ex.InnerException + " - bundle: " + saveBundle, Caller = "AddSchedule", Status = "ERROR", LogDate = System.DateTime.Now.ToLocalTime() }; db.EventureLogs.Add(logE); db.SaveChanges(); if (Request != null) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "There was error with your transaction, please try again.")); } else { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } } }
public async Task <IHttpActionResult> ForgotPassword(ForgotPasswordViewModel model) //(ForgotPasswordViewModel model) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} try { IdentityUser user = await _repo.FindAsync(model.Email); if (user == null) // || !(await UserManager.IsEmailConfirmedAsync(user.Id))) { // User not found. Don't reveal that the user does not exist or is not confirmed? return(Ok()); } var code = await _repo.GeneratePasswordResetTokenAsync(user.Id); code = System.Web.HttpUtility.UrlEncode(code); //var code = System.Web.HttpUtility.urlEncode //var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); //string callbackUrl = this.Url.Link("ResetPassword", new { userId = user.Id, code = code }); //, protocol: Request.Url.Scheme //var callbackUrl = "http://localhost:65468/#/resetpassword?userId=" + code; //var callbackUrl = ConfigurationManager.AppSettings["resetPasswordLink"] + "/#/resetpassword?userId=" + code; //ConfigurationManager.AppSettings["resetPasswordLink"]; //await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>") //await _repo.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>"); //mjb _mailService.SendResetPassword(user.UserName, "Reset Password", "Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>"); HttpResponseMessage result = new MailController().SendResetPassword(user.UserName, code); //ViewBag.Link = callbackUrl; //return View("ForgotPasswordConfirmation"); //IHttpActionResult errorResult = GetErrorResult(result); //if (errorResult != null) //{ // return errorResult; //} //return Ok(); //} // If we got this far, something failed, redisplay form //return View(model); //return Ok(accessTokenResponse); return(Ok()); } catch (Exception ex) { evsContext db = new evsContext(); var logE = new EventureLog(); logE.Message = "Order exception: " + ex.Message + " -- bundle: "; logE.Caller = "Order_ERROR"; logE.Status = "ERROR"; logE.LogDate = System.DateTime.Now.ToLocalTime(); logE.DateCreated = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(logE); db.SaveChanges(); //var badResp = Request.CreateResponse(HttpStatusCode.BadRequest); //badResp.Content = new StringContent(ex.Message, Encoding.UTF8, "text/plain"); //return badResp; return(BadRequest(ex.Message)); } }
public HttpResponseMessage SendTeamPlayerInviteMail(int id) { //needs to be a send amazon email //Type : confirm, reset password // to, cc, bc, sender, reply, subject, text try { var teamMember = db.TeamMembers.Where(m => m.Id == id).Select(m => new { m.TeamMemberGuid, m.Email, m.Name, m.Team.Coach.FirstName, m.Team.Coach.LastName, m.Team.Registration.EventureList.DisplayName, m.Team.TeamGuid, teamName = m.Team.Name, m.Team.Owner.Url, m.Team.Owner.SendImageHtml, m.Team.Owner.SendMailEmailAddress, m.Team.Owner.SendConfirmTeamInviteEmailSubject }).SingleOrDefault(); if (teamMember == null) { throw new Exception("Could not find TeamMember from id: " + id.ToString()); } var addresses = new List <string>(); var mode = ConfigurationManager.AppSettings["MailMode"]; var emailText = string.Empty; var subject = string.Empty; var sender = string.Empty; var ccs = new List <string>(); //i use cc here because it actaully bccs and that is what i want var bcc = new List <string>(); //this is actually bbc //an amazon issue? if (mode == "TEST") { addresses.Add("*****@*****.**"); subject = "TEST: Eventure Sports Confirmation"; sender = "*****@*****.**"; emailText = "<img src=\"http://www.eventuresports.com/Portals/0/Skins/EventureSports_Skin/img/logo.png\"><br><br>"; } else { addresses.Add(teamMember.Email); subject = teamMember.SendConfirmTeamInviteEmailSubject; sender = teamMember.SendMailEmailAddress; ccs.Add("*****@*****.**"); //ccs.Add("*****@*****.**"); ccs.Add(sender); emailText = teamMember.SendImageHtml; } string url = teamMember.Url + "#/team/" + teamMember.TeamGuid.ToString().ToUpper() + "/member/" + teamMember.TeamMemberGuid.ToString().ToUpper() + "/payment"; emailText = emailText + "Date: " + DateTime.Now.ToString("M/d/yyyy") + "<BR>"; emailText = emailText + "Dear " + teamMember.Name + ",<BR><BR>You have been invited by " + teamMember.FirstName + ' ' + teamMember.LastName + " to join team " + teamMember.teamName + " in the " + teamMember.DisplayName; emailText = emailText + ". <BR> Please click on the following link: " + url; //var ses = new AmazonSESWrapper("AKIAIACOACRTWREUKHWA", "eXlslxG5YX2+SKAvBbSuMqeJouwGEDci3cfa7TaV"); //AmazonSentEmailResult mail = ses.SendEmail(addresses, ccs, bcc, sender, sender, subject, emailText); var mailTo = new List <string>(); var ccMail = new List <string>(); mailTo.Add(teamMember.Email); ccMail.Add("*****@*****.**"); //ccs and bcc seem to be reversed MailService _mailService = new MailService(); //var y = _mailService.SendSingleEmail(teamMember.Email, subject, emailText); var x = _mailService.SendEmail(emailText, subject, sender, mailTo, ccMail); return(new HttpResponseMessage(HttpStatusCode.OK)); //if (mail.ErrorException == null) //{ // if (Request != null) // return Request.CreateResponse(HttpStatusCode.OK); // else // return new HttpResponseMessage(HttpStatusCode.OK); //} //else //{ // var log = new EventureLog(); // log.Message = "orderId: " + id + "_email failed" + mail.ErrorException; // log.Caller = "Mail Api_SendConfirmMail"; // log.Status = "Error"; // log.LogDate = System.DateTime.Now.ToLocalTime(); // db.EventureLogs.Add(log); // db.SaveChanges(); // if (Request != null) // return Request.CreateResponse(HttpStatusCode.OK); //change this ?? //mjb // else // { // return new HttpResponseMessage(HttpStatusCode.OK); // } //} } catch (Exception ex) { var logE = new EventureLog(); logE.Message = "orderId: " + id + "_Error Handler: " + ex.Message; logE.Caller = "Mail Api_SendConfirmMail"; logE.Status = "ERROR"; logE.LogDate = System.DateTime.Now.ToLocalTime(); logE.DateCreated = System.DateTime.Now.ToLocalTime(); db.EventureLogs.Add(logE); db.SaveChanges(); if (Request != null) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } else { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } } }