private void ProcessLot(LotEntity lot) { try { lot.IsActive = false; lotService.Update(lot); Debug.Print("Update lot"); if (lot.Bids.Count > 0) { var seller = userService.GetOneByPredicate(u => u.ProfileId == lot.ProfileId); int max = lot.Bids.Max(b => b.Price); var winnerProfileId = lot.Bids.First(b => b.Price == max).ProfileId; var winner = userService.GetOneByPredicate(u => u.ProfileId == winnerProfileId); if ((winner != null) && (seller != null)) { SendAsync(winner.Email, "Action: You are winner!", "Seller is " + seller.Email); SendAsync(seller.Email, "Auction: Your item is sold out", "Winner is " + winner.Email); Debug.Print("Email"); log.Info(string.Format("Auction (LotId: {0}, Name: {1}): Emails were sended successfully!", lot.Id, lot.Name)); } } } catch (ArgumentException ae) { log.Error("Error (mail sending iteration): wrong parameters " + ae.ToString()); } catch (FormatException fe) { log.Error("Error (mail sending iteration): wrong string of address " + fe.ToString()); } catch (Exception e) { log.Error("Error (mail sending iteration): " + e.ToString()); } }
public ActionResult Verify(int?id) { var lot = lotService.GetById(id.Value); lot.IsChecked = true; lot.IsActive = true; lotService.Update(lot); return(RedirectToAction("ShowUnchecked", "Home")); }
public ActionResult Edit(LotViewModel lotViewModel) { if (ModelState.IsValid) { if (lotViewModel.Seller.Email == User.Identity.Name || User.IsInRole("admin")) { var lot = Mapper.Map <Lot>(lotViewModel); lotService.Update(lot); return(View(lotViewModel)); } else { return(new HttpUnauthorizedResult()); } } return(View(lotViewModel)); }