public List <(int PlantId, string PlantName)> GetPlants() { return(PlantsInfoRepository.GetCompanyPlants(_company). Where(plant => plant.IsFree). Select <Plant, (int PlantId, string PlantName)> (plant => (plant.Id, plant.Name)). ToList()); }
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(); }