Пример #1
0
 /// <summary>
 /// Разбиаение на страницы
 /// </summary>
 /// <param name="productPage"></param>
 /// <returns></returns>
 public IActionResult List(int productPage = 1) =>
 View(new ProductsListViewModel
 {
     Products = _mapper.Map <List <ProductModel> >(_productRepo.GetAll())
                .OrderBy(x => x.Name)
                .Skip((productPage - 1) * _pageSize)
                .Take(_pageSize),
     pagingInfo = new PagingInfo
     {
         CurrentPage  = productPage,
         ItemsPerPage = _pageSize,
         TotalItems   = _productRepo.GetAll().Count()
     }
 });
Пример #2
0
        ///<inheritdoc cref="IMessageSendService.SendEmail(SmtpClient, Message)"/>
        public async Task SendEmailNow(string smtpServer, IEnumerable <MailMessage> mailMessages, bool isSheduled = false)
        {
            if (isSheduled == false)
            {
                try
                {
                    DataValidate(smtpServer, mailMessages);
                }
                catch (EmailSendServiceException ex)
                {
                    throw ex;
                }
            }

            var sender            = _senderRepository.GetAll().Where(x => x.Email == mailMessages.FirstOrDefault().From.Address).FirstOrDefault().ToDomain();
            var allRecipients     = _recipientRepository.GetAll();
            var messageRecipients = new List <Recipient>();

            using (var client = GetSmtpClient(sender, smtpServer))
            {
                foreach (var mail in mailMessages)
                {
                    var recipient = allRecipients.Where(x => x.Email == mail.To.FirstOrDefault().Address).FirstOrDefault();
                    messageRecipients.Add(recipient.ToDomain());
                    await client.SendMailAsync(mail);
                }
            }

            if (isSheduled == false)
            {
                var sendedMessage = new Message()
                {
                    SenderId     = sender.Id,
                    Body         = mailMessages.FirstOrDefault().Body,
                    Title        = mailMessages.FirstOrDefault().Subject,
                    SendDateTime = DateTime.Now
                };
                _messageRepository.Add(sendedMessage.ToEntity());
            }
            ;

            foreach (var rec in messageRecipients)
            {
                _recipient2MessageRepository.Add(new Recipient2MessageEntity()
                {
                    MessageId   = _messageRepository.GetAll().Select(x => x.Id).LastOrDefault(),
                    RecipientId = rec.Id
                });
            }
        }
Пример #3
0
        public IActionResult Index()
        {
            var product = _mapper.Map <ProductModel>(_productRepo.GetAll().FirstOrDefault());

            ViewBag.Add = "supaDupa";
            return(View(product));
        }
Пример #4
0
 private SmtpClient GetSmtpClient(Sender sender, string smtpServer)
 {
     return(new SmtpClient()
     {
         Host = smtpServer,
         Port = _hostRepository.GetAll()
                .Where(x => x.Server == smtpServer)
                .Select(x => x.Port)
                .FirstOrDefault(),
         EnableSsl = true,
         DeliveryMethod = SmtpDeliveryMethod.Network,
         UseDefaultCredentials = false,
         Credentials = new NetworkCredential(sender.Email, PasswordCoding.Decrypt(sender.Password))
     });
 }
Пример #5
0
        public IEnumerable <PnLReport> GetReport(string symbol, DateTime asofDate)
        {
            var tradesum     = tradeSummaryRepo.GetAll();
            var priceHistory = priceHistoryRepo.GetAll();

            var result = from t1 in tradesum
                         join t2 in priceHistory
                         on t1.Ticker.Symbol equals t2.Symbol into ps
                         from t2 in ps.DefaultIfEmpty()
                         where (t1.Ticker.Symbol == symbol || symbol == "--All--")
                         select new PnLReport {
                Ticker           = t1.Ticker.Symbol,
                AsOfDate         = t2.PriceDateTime,
                TotalAmount      = t1.Quantity * t1.UnitPrice,
                TotalAmountwCost = t1.Quantity * t1.UnitPriceWithCost,
                Quantity         = t1.Quantity,
                Price            = t2.Open,
                PrevClose        = t2.Close,
            };

            return(result.Where(p => p.AsOfDate.Date == asofDate.Date).ToList());
        }
        public virtual ICollection <T> GetAll()
        {
            ICollection <T> _result = repo.GetAll();

            return(_result);
        }
Пример #7
0
 public async Task <IActionResult> Get()
 {
     return(Ok(await _context.GetAll()));
 }
Пример #8
0
 // GET: Student
 public async Task <IActionResult> Index()
 {
     return(View(await _context.GetAll()));
 }
Пример #9
0
 public IEnumerable <Host> GetAll()
 {
     return(_repository.GetAll().Select(x => x.ToDomain()));
 }