public void ProcessOrder(Cart cart, ShoppingDetail detail) { using (var stmpClient = new SmtpClient()) { stmpClient.EnableSsl = emailsettings.UserSsl; stmpClient.Host = emailsettings.ServerName; stmpClient.Port = emailsettings.ServerPort; stmpClient.UseDefaultCredentials = false; stmpClient.Credentials = new NetworkCredential(emailsettings.UserName, emailsettings.UserPassword); if (emailsettings.WriteAsfile) { stmpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; stmpClient.PickupDirectoryLocation = emailsettings.FileLocation; stmpClient.EnableSsl = false; } StringBuilder body = new StringBuilder() .AppendLine("새 주문이 제출 되었습니다.") .AppendLine("==============") .AppendLine("Items"); foreach (var line in cart.cartLine) { var subTotal = line.Product.Price * line.Quantity; body.AppendFormat("{0} x {1} (subtotal: {2:c}", line.Quantity, line.Product.Name, subTotal); } body.AppendFormat("Total order value: {0:c}", cart.ComputeTotalValue()) .AppendLine("=======") .AppendLine("ship to") .AppendLine(detail.Name) .AppendLine(detail.Line1) .AppendLine(detail.Line2 ?? "") .AppendLine(detail.Line3 ?? "") .AppendLine(detail.City) .AppendLine(detail.State ?? "") .AppendLine(detail.Country) .AppendLine(detail.Zip) .AppendLine("-----") .AppendFormat("선물 옵션: {0}", detail.GiftWarp); MailMessage mail = new MailMessage( emailsettings.MailFromAddress, emailsettings.MailToAddress, "새로운 주문!", body.ToString()); if (emailsettings.WriteAsfile) { mail.BodyEncoding = Encoding.ASCII; } stmpClient.Send(mail); } }
public async Task DeleteShoppingDetail(ShoppingDetail shoppingDetail) { await Task.Run(() => { try { connection.Delete <ShoppingDetail>(shoppingDetail.ShoppingDetailId); } catch (Exception ex) { Debug.WriteLine(ex.Message); throw; } }); }
public async Task SaveShoppingDetail(ShoppingDetail shoppingDetail) { await Task.Run(() => { try { connection.InsertOrReplaceWithChildren(shoppingDetail); } catch (Exception ex) { Debug.WriteLine(ex.Message); throw; } }); }
public ViewResult Checkout(Cart cart, ShoppingDetail detail) { if (cart.cartLine.Count() == 0) { ModelState.AddModelError("", "카드가 비었습니다."); } if (ModelState.IsValid) { orderRepo.ProcessOrder(cart, detail); cart.Clear(); return(View("Completed")); } else { return(View(detail)); } }
private bool Validate(ShoppingDetail shoppingDetail) { bool error = false; if (!(int.TryParse(shoppingDetail.GevraagdAantal.ToString(), out int result))) { error = true; //lblErrorTitle.Text = "Title cannot be empty"; //lblErrorTitle.IsVisible = true; } if (!error) { //lblErrorTitle.Text = ""; //lblErrorTitle.IsVisible = false; //lblErrorDescription.Text = ""; //lblErrorDescription.IsVisible = false; } return(!error); }
public async override void ReverseInit(object returnedData) { var NieuwProductvoorShoppingList = returnedData as Product; if (!ShoppingDetails.Any(x => x.Product.ProductId == NieuwProductvoorShoppingList.ProductId)) { ShoppingDetail nieuwSD = new ShoppingDetail { ShoppingDetailId = Guid.NewGuid(), Product = NieuwProductvoorShoppingList, // Scanned = false, GescannedAantal = 0, GevraagdAantal = 1 }; ShoppingDetails.Add(nieuwSD); await appModelService.SaveShoppingDetail(nieuwSD); currentShoppingList.ShoppingDetails = ShoppingDetails; await appModelService.SaveShoppingList(currentShoppingList); } await RefreshShoppingList(); }
public async Task SetScannedProductFromShoppingList(ShoppingList shoppingList, string s) { ShoppingDetail sd = new ShoppingDetail(); ShoppingList sl = new ShoppingList(); await Task.Run(() => { try { // doet het niet. Product = null..... tiens. //sd = connection.Table<ShoppingList>(). //Where(e => e.ShoppingListId == shoppingList.ShoppingListId).FirstOrDefault().ShoppingDetails. //Where(f => f.Product.Result == s). //FirstOrDefault(); //sd.GescannedAantal = sd.GescannedAantal--; //connection.InsertOrReplaceWithChildren(sd); // daarom: sl = connection.Table <ShoppingList>(). Where(e => e.ShoppingListId == shoppingList.ShoppingListId).First(); if (sl != null) { connection.GetChildren <ShoppingList>(sl, true); sd = sl.ShoppingDetails.Where(e => e.Product.Result == s).FirstOrDefault(); if (!(sd == null)) { sd.GescannedAantal = sd.GescannedAantal + 1; connection.InsertOrReplaceWithChildren(sd); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); throw; } }); }
public Task DeleteShoppingDetail(ShoppingDetail shoppingDetail) { throw new NotImplementedException(); }