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(); }
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(); }
public Order GetOrderById(int id) { return(OrderCompanyRepository.GetOrder(id)); }
public void DeleteOrder(int orderId) { OrderCompanyRepository.CancelOrder(OrderCompanyRepository.GetOrder(orderId)); OrderCompanyRepository.SaveChages(); }