public static async Task SendMail(String mailcontent, String address, String subject) { DealRepository dealRepo = new DealRepository(new SSMEntities()); var body = "{0}"; var message = new MailMessage(); message.To.Add(new MailAddress(address)); // replace with valid value message.From = new MailAddress("*****@*****.**"); // replace with valid value message.Subject = subject; SSMEntities context = new SSMEntities(); message.Body = string.Format(body, mailcontent); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { UserName = "******", // replace with valid value Password = "******" // replace with valid value }; smtp.Credentials = credential; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; await smtp.SendMailAsync(message); System.Diagnostics.Debug.WriteLine("yay ?"); } }
public ActionResult GetAll() { DealRepository repository = new DealRepository(); ModelState.Clear(); return(View(repository.GetAll("GetDealsJoin", true))); }
public void GetDealReturnsJson() { var repository = new DealRepository(); var result = repository.GetDeal(); Assert.That(result, Is.InstanceOf <ContentResult>()); Assert.AreEqual(result.ContentType, "application/json"); }
public ActionResult AddDeals(int id) { DealRepository repository = new DealRepository(); ModelState.Clear(); ViewBag.AuctionId = id; return(View(repository.GetForAuction(id))); }
public void GetDealReturnsBundle() { var repository = new DealRepository(); var result = repository.GetDeal(); var obj = JObject.Parse((string)result.Content); int val; Assert.IsTrue(int.TryParse((string)obj["bundleId"], out val)); }
public UnitOfWork(ApplicationDbContext dbContext) { _dbContext = dbContext; Offers = new OrderOffersRepository(_dbContext); Categories = new CategoryRepository(_dbContext); Users = new UserRepository(_dbContext); Deals = new DealRepository(_dbContext); Notifications = new NotificationRepository(_dbContext); }
public void DealController_GetAllTestCase() { DealContext dbContext = LoadDependencies <DealContext>(); var mockRepo = new DealRepository(dbContext); var logger = new FlatFileLogger(); var controller = new DealController(mockRepo, logger); var result = controller.Get(); Assert.NotNull(result); var lstDeal = Assert.IsAssignableFrom <IList <Deal> >((result as OkObjectResult).Value as IList <Deal>); Assert.Equal(2, lstDeal.Count); }
// GET: TradingProgress/Edit/5 public ActionResult Edit(int id) { TradingProgressRepository repository = new TradingProgressRepository(); ParticipantRepository participantRep = new ParticipantRepository(); DealRepository dealRep = new DealRepository(); TradingProgressModel model = repository.GetById(id); model.Buyers = participantRep.GetAll(); model.Deals = dealRep.GetAll(); return(View(model)); }
// GET: TradingProgress/Create public ActionResult Create() { ParticipantRepository participantRep = new ParticipantRepository(); DealRepository dealRep = new DealRepository(); TradingProgressModel model = new TradingProgressModel { Buyers = participantRep.GetAll(), Deals = dealRep.GetAll() }; return(View(model)); }
public void DealController_GetDealTestCase() { DealContext dbContext = LoadDependencies <DealContext>(); var mockRepo = new DealRepository(dbContext); var logger = new FlatFileLogger(); var controller = new DealController(mockRepo, logger); var result = controller.GetDealsByCountryId(1); Assert.NotNull(result); var deal = Assert.IsAssignableFrom <Deal>((result as OkObjectResult).Value as Deal); Assert.Equal(1, deal.country_id); }
public ActionResult Edit(int id, DealModel ModelObject) { try { DealRepository repository = new DealRepository(); repository.Update(ModelObject); return(RedirectToAction("GetAll")); } catch { return(View()); } }
// GET: Deal/Delete/5 public ActionResult Delete(int id) { try { DealRepository repository = new DealRepository(); repository.Delete(id); return(RedirectToAction("GetAll")); } catch { return(View()); } }
public void DealWon(int id, String userID) { SSMEntities se = new SSMEntities(); DealRepository dealrepo = new DealRepository(se); Deal deal = dealrepo.getByID(id); if (deal != null) { deal.Status = 3; customer cus = new customer(); cus.userID = userID; cus.cusAddress = deal.contact.Street + " " + deal.contact.City + " " + deal.contact.Region + " "; cus.cusCompany = 1; cus.cusEmail = deal.contact.emails; cus.cusName = deal.contact.FirstName + " " + deal.contact.MiddleName + " " + deal.contact.LastName; cus.cusPhone = deal.contact.Phone; se.customers.Add(cus); se.SaveChanges(); try { order order = new order(); order.customerID = cus.id; float price = 0; order.orderNumber = 123123123; order.subtotal = deal.Value; order.status = 1; order.total = (double)order.subtotal * 1.1; order.VAT = (double)order.subtotal * 0.1; Storage storeage = new Storage(); se.orders.Add(order); se.SaveChanges(); order.Contract = storeage.uploadfile(userID, "order" + order.id); se.SaveChanges(); MarketPlanPurchased mp = new MarketPlanPurchased(); mp.orderID = order.id; mp.planID = deal.productMarketPlan.id; mp.productID = deal.productMarketPlan.productID; mp.SoldPrice = (double)deal.Value; mp.quantity = deal.Quantity; se.MarketPlanPurchaseds.Add(mp); se.SaveChanges(); deal.Status = 5; se.SaveChanges(); } catch (Exception e) { } } }
public ActionResult Next(int auctionId, int dealId) { try { AuctionRepository auctionRepository = new AuctionRepository(); auctionRepository.End(auctionId); DealRepository dealRepository = new DealRepository(); dealRepository.NoActive(dealId); return(RedirectToAction("Start", "AuctionManage", new { id = auctionId })); } catch { return(RedirectToAction("Start", "AuctionManage", new { id = auctionId })); } }
// GET: Deal/Edit/5 public ActionResult Edit(int id) { DealRepository repository = new DealRepository(); AuctionRepository auctionRep = new AuctionRepository(); ParticipantRepository participantRep = new ParticipantRepository(); DealStateRepository dealStateRep = new DealStateRepository(); ItemRepository itemRep = new ItemRepository(); DealModel model = repository.GetById(id); model.Auctions = auctionRep.GetAll(); model.Buyers = participantRep.GetAll(); model.Sellers = participantRep.GetAll(); model.DealStates = dealStateRep.GetAll(); model.Items = itemRep.GetAll(); return(View(model)); }
public ActionResult Create(DealModel ModelObject) { try { if (ModelState.IsValid) { DealRepository repository = new DealRepository(); repository.Add(ModelObject); return(RedirectToAction("GetAll")); } return(View()); } catch { return(View()); } }
public ActionResult NewDeal(DealModel ModelObject) { try { if (ModelState.IsValid) { DealRepository dealRepository = new DealRepository(); ItemRepository itemRepository = new ItemRepository(); itemRepository.SetSold(ModelObject.Item_Id); dealRepository.Add(ModelObject); return(RedirectToAction("AddDeals", "AuctionManage", new { id = ModelObject.Auction_Id })); } return(View()); } catch { return(View()); } }
private void addDealButton_Click(object sender, EventArgs e) { var addDealForm = new AddDealForm(); DialogResult dialogResult = addDealForm.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } int readerId = addDealForm.SelectedReader.Id; var dealRepository = new DealRepository(); var bookCopyInDealRepository = new BookCopyInDealRepository(); BookCopyInDeal bookCopyInDeal; var bookCopyRepository = new BookCopyRepository(); Deal deal = new Deal { LibrarianId = _librarianId, ReaderId = readerId, Date = DateTime.UtcNow }; dealRepository.Create(deal); var p = addDealForm.booksDataGridView.SelectedRows; for (int i = 0; i < p.Count; i++) { bookCopyInDeal = new BookCopyInDeal { DealId = deal.Id, BookCopyId = bookCopyRepository.GetAvailableBookCopiesByBookId((int)p[i].Cells[0].Value)[0].Id, RequiredDateOfReturning = DateTime.UtcNow.AddDays((int)addDealForm.daysNumericUpDown.Value) }; bookCopyInDealRepository.Create(bookCopyInDeal); } }
private static void ShowMainWindow() { var eventStoreClient = new EventStoreClient(); var messageBusClient = new MessageBusClient(); var dealEntryCommandHander = new DealEntryCommandHandler(messageBusClient, eventStoreClient); var dealRepo = new DealRepository(eventStoreClient, messageBusClient); dealEntryCommandHander.Start(); var window = new MainWindow(); var dealCaptureVm = new ActiveDealDashboardViewModel(dealRepo); window.DataContext = dealCaptureVm; using (dealCaptureVm.Start()) { window.ShowDialog(); } dealEntryCommandHander.Dispose(); messageBusClient.Dispose(); eventStoreClient.Dispose(); }
// GET: AuctionManage/Edit/5 public ActionResult Start(int id) { DealRepository dealRepository = new DealRepository(); ParticipantRepository participantRepository = new ParticipantRepository(); ItemRepository itemRepository = new ItemRepository(); IEnumerable <DealModel> dealsForAuction = dealRepository.GetForAuction(id); StartViewModel startViewModel = new StartViewModel { deals = dealsForAuction, participants = participantRepository.GetAll() }; ModelState.Clear(); ViewBag.AuctionId = id; if (dealsForAuction.Count() > 0) { ItemModel firstDealItem = itemRepository.GetById(startViewModel.deals.ElementAt(0).Item_Id); ViewBag.startPrice = firstDealItem.StartedPrice; ViewBag.dealStep = firstDealItem.PriceGrowth; } return(View(startViewModel)); }
public void deleteButton_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { int index = dataGridView1.SelectedRows[0].Index; int id = 0; bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id); if (converted == false) { return; } var readerRepository = new ReaderRepository(); var dealRepository = new DealRepository(); var bookCopyInDealRepository = new BookCopyInDealRepository(); List <Deal> deals = dealRepository.GetDealsByReaderId(id); List <BookCopyInDeal> bookCopyInDeals = bookCopyInDealRepository.GetBookCopiesInDealByReaderId(id); for (int i = 0; i < bookCopyInDeals.Count; i++) { bookCopyInDealRepository.Remove(bookCopyInDeals[i].Id); } for (int i = 0; i < deals.Count; i++) { dealRepository.Remove(deals[i].Id); } readerRepository.Remove(id); _db.SaveChanges(); SetDataGridView(); MessageBox.Show("Объект удален"); } }
public DealServiceImpl() { this.dealRepository = new DealRepositoryImpl(); this.productDealRepository = new ProductDealRepositoryImpl(); }
public ActionResult DealWon(int id) { SSMEntities se = new SSMEntities(); DealRepository dealrepo = new DealRepository(se); Deal deal = dealrepo.getByID(id); if (deal != null) { customer cus = new customer(); if (se.AspNetUsers.Where(us => us.UserName.Equals(deal.contact.emails)).FirstOrDefault() == null) { cus.cusAddress = deal.contact.Street + " " + deal.contact.City + " " + deal.contact.Region + " "; cus.cusCompany = 1; cus.cusEmail = deal.contact.emails; cus.cusName = deal.contact.FirstName + " " + deal.contact.MiddleName + " " + deal.contact.LastName; cus.cusPhone = deal.contact.Phone; se.customers.Add(cus); se.SaveChanges(); AccountController ac = new AccountController(); String cusAccountID = ac.RegisterNewAccount(cus.cusEmail, "320395@qwE", System.Web.HttpContext.Current, "Customer"); cus.userID = cusAccountID; se.SaveChanges(); } else { AspNetUser thiscus = se.AspNetUsers.Where(us => us.UserName.Equals(deal.contact.emails)).First(); cus = thiscus.customers.First(); } deal.Status = 3; order order = new order(); order.customerID = cus.id; float price = 0; order.orderNumber = se.orders.ToList().Count() + 1; order.subtotal = deal.Value; order.status = 1; order.total = (double)order.subtotal * 1.1; order.VAT = (double)order.subtotal * 0.1; order.fromDeal = deal.id; order.createDate = DateTime.Now; Storage storeage = new Storage(); se.orders.Add(order); se.SaveChanges(); order.Contract = storeage.uploadfile(cus.userID, "order" + order.id); se.SaveChanges(); deal.Status = 3; se.SaveChanges(); bool validLicense = true; foreach (Deal_Item dealitem in deal.Deal_Item) { int lcount = se.Licenses.Where(u => u.PlanID == dealitem.planID && u.status == null && u.SaleRepResponsible == null).Count(); if (lcount < dealitem.Quantity) { validLicense = false; } } if (validLicense) { foreach (Deal_Item dealitem in deal.Deal_Item) { for (int i = 0; i < dealitem.Quantity; i++) { License license = se.Licenses.Where(u => u.PlanID == dealitem.planID && u.status == null && u.SaleRepResponsible == null).FirstOrDefault(); if (license != null) { license.customerID = cus.id; license.SaleRepResponsible = deal.Deal_SaleRep_Respon.LastOrDefault().userID; license.status = 1; OrderItem orderItem = new OrderItem(); orderItem.orderID = order.id; orderItem.planID = dealitem.planID; orderItem.SoldPrice = (double)dealitem.price; orderItem.LicenseID = license.id; se.OrderItems.Add(orderItem); } else { return(RedirectToAction("Detail", new { id = deal.id })); } } } se.SaveChanges(); } else { return(RedirectToAction("Detail", new { id = deal.id })); } Notification noti = new Notification(); noti.NotiName = "Contract successfully created"; noti.NotiContent = "Deal No." + deal.id + ": has finished with a contract and order"; noti.userID = deal.Deal_SaleRep_Respon.LastOrDefault().userID; noti.CreateDate = DateTime.Now; noti.viewed = false; noti.hreflink = "/Deal/Detail?id=" + deal.id; se.Notifications.Add(noti); se.SaveChanges(); deal.Status = 5; se.SaveChanges(); //} //catch (Exception e) { // return Json(new { result = "sad" }, JsonRequestBehavior.AllowGet); //} } return(RedirectToAction("Detail", new { id = deal.id })); }
public TradeModel(TradeSessionRepository TradeSessionRepository, CandleRepository CandleRepository, OrderRepository OrderRepository, PositionRepository PositionRepository, DealRepository DealRepository, WebApiClient client, ITradeMode mode, Mode modeProperties, object token) { _token = token; _tradeSessionRepository = TradeSessionRepository; _candleRepository = CandleRepository; _orderRepository = OrderRepository; _positionRepository = PositionRepository; _dealRepository = DealRepository; _apiClient = client; _mode = mode; _modeProperties = modeProperties; _candles = new Dictionary <string, IDictionary <string, IList <ICandle> > >(); Messenger.Default.Register <InitTradeModelMessage>(this, _token, async(msg) => { var temp_sessions = await _tradeSessionRepository.GetAll(); _sessions = temp_sessions.OrderBy(t => t.Date).ToList(); _mode.SetAction("init", () => { foreach (string sec in msg.securities) { _candles[sec] = new Dictionary <string, IList <ICandle> >(); foreach (string frame in msg.frames) { string res = InitCandles(sec, frame).Result; } } }); _mode.SetAction("initEmpty", () => { foreach (string sec in msg.securities) { _candles[sec] = new Dictionary <string, IList <ICandle> >(); foreach (string frame in msg.frames) { _candles[sec][frame] = new List <ICandle>(); } } }); _mode.SetAction("update", () => { IEnumerable <Candle> candles = _candleRepository.GetAll().Result; _positionlist = _positionRepository.GetAll().Result; foreach (string sec in msg.securities) { var tempData = candles.Where(c => c.Code == sec).OrderBy(c => c.begin); UpdateCadles(sec, tempData, msg.frames); } this._positions = GetPositions(_positionlist, msg.securities); }); _mode.SetAction("sendToRobo", () => { Messenger.Default.Send <GetCandlesResponseMessage>(new GetCandlesResponseMessage() { DateTime = mode.GetDate(), Сandles = _candles, Positions = _positions }, _token); }); _mode.SetAction("showData", () => { _dealRepository.GetAll().ContinueWith(t => { Messenger.Default.Send <ShowDataMessage>(new ShowDataMessage() { Сandles = CopyCandles(_candles), Deals = t.Result, Positions = _positionlist }); }); }); mode.Start(); }); Messenger.Default.Register <CreateOrderMessage>(this, msg => { Order order = new Order() { Code = msg.Code, OrderOperation = msg.OrderOperation, Account = _modeProperties.Account, Price = msg.Price, Count = msg.Count, Class = _modeProperties.Class, Client = _modeProperties.Client, Comment = _modeProperties.Client, Profit = msg.Profit, StopLoss = msg.StopLoss }; string result = _orderRepository.Create(order).Result; }); //Messenger.Default.Register<GetCandlesMessage>(this, (msg) => //{ // Messenger.Default.Send<GetCandlesResponseMessage>(new GetCandlesResponseMessage() // { // Сandles = _candles // }); //}); Messenger.Default.Register <ClosePositionMessage>(this, msg => { string result = _apiClient.GetData(string.Format("{0}admin/ClosePosition?sec={1}", this.ServerURL, msg.Code)).Result; }); }
public static DealRepository GetDealRepository(IUnitOfWork unitOfWork) { var repository = new DealRepository(); repository.UnitOfWork = unitOfWork; return repository; }
public static List <string[]> Main_(string member) { List <string[]> result = new List <string[]>(); Entity[] temp; switch (member) { case "Buyer": BuyerRepository buyer = new BuyerRepository(Global.ConnectionStringSql, Global.ProviderName); temp = buyer.GetAll().ToArray <Entity>(); Buyer[] buyers = new Buyer[temp.Length]; for (int i = 0; i < temp.Length; i++) { buyers[i] = (Buyer)temp[i]; } for (int i = 0; i < buyers.Length; i++) { result.Add(new string[5]); result[i][0] = buyers[i].Id.ToString(); result[i][1] = buyers[i].CreationDate.ToString(); result[i][2] = buyers[i].DeletedDate.ToString(); result[i][3] = buyers[i].Name.ToString(); result[i][4] = buyers[i].Surname.ToString(); } break; case "Deal": DealRepository deal = new DealRepository(Global.ConnectionStringSql, Global.ProviderName); temp = deal.GetAll().ToArray <Entity>(); Deal[] deals = new Deal[temp.Length]; for (int i = 0; i < temp.Length; i++) { deals[i] = (Deal)temp[i]; } for (int i = 0; i < deals.Length; i++) { result.Add(new string[7]); result[i][0] = deals[i].Id.ToString(); result[i][1] = deals[i].CreationDate.ToString(); //result[i][2] = deals[i].DeletedDate.ToString(); result[i][3] = deals[i].IdBuyer.ToString(); result[i][4] = deals[i].IdSeller.ToString(); result[i][5] = deals[i].Summ.ToString(); result[i][6] = deals[i].Date.ToString(); } break; case "Saller": SallerRepository saller = new SallerRepository(Global.ConnectionStringSql, Global.ProviderName); temp = saller.GetAll().ToArray <Entity>(); Saller[] sallers = new Saller[temp.Length]; for (int i = 0; i < temp.Length; i++) { sallers[i] = (Saller)temp[i]; } for (int i = 0; i < sallers.Length; i++) { result.Add(new string[5]); result[i][0] = sallers[i].Id.ToString(); result[i][1] = sallers[i].CreationDate.ToString(); //result[i][2] = sallers[i].DeletedDate.ToString(); result[i][3] = sallers[i].Name.ToString(); result[i][4] = sallers[i].Surname.ToString(); } break; } return(result); }