コード例 #1
0
ファイル: Order.cs プロジェクト: Sateanu/DevHacksBackEnd
 internal Orders ToEntity()
 {
     Orders order = new Orders();
     order.Discount = Discount;
     order.Id = Id;
     order.RestaurantID = RestaurantID;
     order.Price = Price;
     order.Time = Time;
     order.Longitude = Longitude;
     order.Latitude = Latitude;
     order.UserID = UserID;
     order.Done = Done;
     order.ClusterID = ClusterID;
     order.Location = Location;
     foreach (var so in Suborders)
     {
         order.Suborders.Add(so.ToEntity());
     }
     return order;
 }
コード例 #2
0
 private void KronkPullTheLever(Orders order)
 {
     SetOrderDone(order);
     SendTheOwl(order);
     //SendTheOwl("*****@*****.**");
 }
コード例 #3
0
 public void SetOrderDone(Orders order)
 {
     order.Done = 1;
     db.Entry(order).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
コード例 #4
0
        public bool SendTheOwl(Orders order)
        {
            if (order.Restaurants.Email == null)
                return false;

            MailMessage msg = new MailMessage();

            msg.From = new MailAddress("*****@*****.**");
            msg.To.Add(order.Restaurants.Email);
            msg.Subject = "Comanda Mancare";
            //msg.Body = "MERGE BAAAA";
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Locatia :\n{0}\n", order.Location);
            sb.AppendLine("Comanda:");
            foreach (var suborder in order.Suborders)
            {
                sb.AppendFormat("{0} x {1} - Pret: {2}\n", suborder.Foods.Name, suborder.Quantity, suborder.Foods.Price*suborder.Quantity);
            }
            sb.AppendFormat("TOTAL: {0}\n", order.Price);
            msg.Body = sb.ToString();
            SmtpClient client = new SmtpClient();
            client.UseDefaultCredentials = true;
            client.Host = "smtp.gmail.com";
            client.Port = 587;
            client.EnableSsl = true;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.Credentials = new NetworkCredential("*****@*****.**", "zewycawzedktrfvj");
            client.Timeout = 20000;
            try
            {
                client.Send(msg);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
            finally
            {
                msg.Dispose();
            }
        }