Ejemplo n.º 1
0
        public void FinishOrder(int OrderId)
        {
            Order order = OrderCompanyRepository.GetOrder(OrderId);

            try
            {
                string messageBody = $"Order #{order.Id} Finished!" + Environment.NewLine +
                                     $"Product: {order.CompanieProduct.Product.Name}" + Environment.NewLine +
                                     $"Count: {order.Count}" + Environment.NewLine +
                                     $"Price: {order.Count * order.CompanieProduct.Cost}" + Environment.NewLine +
                                     $"Finish date: {order.FinishDate.ToString()}" + Environment.NewLine +
                                     $"Company: {order.CompanieProduct.Company.Name}" + Environment.NewLine +
                                     $"Company number: {order.CompanieProduct.Company.MobileNumber}" + Environment.NewLine +
                                     $"Company email: {order.CompanieProduct.Company.Email}" + Environment.NewLine;
                string messageSubject = "Order #" + order.Id + " Finished";
                var    sender         = new MailAddress("*****@*****.**");
                var    reciver        = new MailAddress(order.Customer.Email);
                string password       = "******";
                var    mail           = new MailMessage();
                mail.From = sender;
                mail.To.Add(reciver);
                mail.Subject = messageSubject;
                mail.Body    = messageBody;
                var client = new SmtpClient("smtp.gmail.com", 587);
                client.EnableSsl   = true;
                client.Credentials = new NetworkCredential(sender.Address, password);
                client.Send(mail);
            }
            catch
            {
                return;
            }
            OrderCompanyRepository.FinishOrder(order);
            OrderCompanyRepository.SaveChages();
        }
Ejemplo n.º 2
0
 public List <(int OrderId, string ProductName, string CustomerName, string FinishDate, int Count, double Cost)> GetNewOrders()
 {
     return(OrderCompanyRepository.GetCompanyNewOrders(_company).
            Select <Order, (int orderId, string productName, string customerName, string finishDate, int count, double cost)>
                (order =>
                (
                    order.Id,
                    order.CompanieProduct.Product.Name,
                    order.Customer.Name,
                    (order.FinishDate.Day.ToString() + "." +
                     order.FinishDate.Month.ToString() + "." +
                     order.FinishDate.Year.ToString()),
                    order.Count,
                    order.CompanieProduct.Cost * order.Count
                )).ToList());
 }
Ejemplo n.º 3
0
        public void ConfirmNewOrder(int OrderId, int PlantId, DateTime StartPlantWork, DateTime FinishPlantWork)
        {
            Order order = OrderCompanyRepository.GetOrder(OrderId);
            Plant plant = PlantsInfoRepository.GetPlantById(PlantId);

            try
            {
                string messageBody = $"Order #{order.Id} Started!" + Environment.NewLine +
                                     $"Product: {order.CompanieProduct.Product.Name}" + Environment.NewLine +
                                     $"Count: {order.Count}" + Environment.NewLine +
                                     $"Price: {order.Count * order.CompanieProduct.Cost}" + Environment.NewLine +
                                     $"Finish date: {order.FinishDate.ToString()}" + Environment.NewLine +
                                     $"Company: {order.CompanieProduct.Company.Name}" + Environment.NewLine +
                                     $"Company number: {order.CompanieProduct.Company.MobileNumber}" + Environment.NewLine +
                                     $"Company email: {order.CompanieProduct.Company.Email}" + Environment.NewLine;
                string messageSubject = "Order #" + order.Id + " Started";
                var    sender         = new MailAddress("*****@*****.**");
                var    reciver        = new MailAddress(order.Customer.Email);
                string password       = "******";
                var    mail           = new MailMessage();
                mail.From = sender;
                mail.To.Add(reciver);
                mail.Subject = messageSubject;
                mail.Body    = messageBody;
                var client = new SmtpClient("smtp.gmail.com", 587);
                client.EnableSsl   = true;
                client.Credentials = new NetworkCredential(sender.Address, password);
                client.Send(mail);
            }
            catch
            {
                return;
            }
            OrderDetail orderDetail = new OrderDetail
            {
                Order = order,
                Plant = plant,
                StartWorkPlantDate  = StartPlantWork,
                FinishWorkPlantDate = FinishPlantWork
            };

            OrderCompanyRepository.ConfirmNewOrder(order, orderDetail);
            OrderCompanyRepository.SaveChages();
        }
Ejemplo n.º 4
0
 public Order GetOrderById(int id)
 {
     return(OrderCompanyRepository.GetOrder(id));
 }
Ejemplo n.º 5
0
 public void DeleteOrder(int orderId)
 {
     OrderCompanyRepository.CancelOrder(OrderCompanyRepository.GetOrder(orderId));
     OrderCompanyRepository.SaveChages();
 }