public void FillDay(DateTime day, string machine) { var tempDB = db.WashTimes.ToList(); List <WashTime> temp = new List <WashTime>(); for (int i = 6; i < 24; i++) { if (!tempDB.Any( t => t.Time.Hour == i && t.Time.Date == day.Date && t.Machine == machine)) { day = day.AddHours(i); temp.Add( new WashTime { IsBooked = false, Machine = machine, Time = day, RoomNumber = 0 } ); } } db.WashTimes.AddRange(temp); db.SaveChanges(); }
public MainWindow() { InitializeComponent(); WashContext context = new WashContext(); context.Washes.Add(new Wash { Date = DateTime.Now, Price = 10 }); context.SaveChanges(); }
public bool EventApproved(BarBookingVM barBooking) { if (ModelState.IsValid) { var booking = db.BarBookings.Find(barBooking.Id); if (booking == null) { return(false); } booking.Status = (int)BarBookingStatus.BookingApproved; db.Entry(booking).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception) { return(false); } //SmtpClient client = new SmtpClient //{ // Port = 587, // DeliveryMethod = SmtpDeliveryMethod.Network, // UseDefaultCredentials = false, // Credentials = new NetworkCredential(ConfigurationManager.AppSettings["sendMailUser"], ConfigurationManager.AppSettings["sendMailPassword"]), // Host = "smtp.unoeuro.com" //}; //var body = "<p>Din betaling til booking af baren: d. {0} er registeret </p>"; //var message = new MailMessage(); //message.From = (new MailAddress("*****@*****.**", "Vaskeriet OMA")); //replace with valid value //message.To.Add(new MailAddress(booking.Email)); //message.Subject = "Booking ad baren til " + barBooking.Name; //message.Body = string.Format(body, barBooking.StartTime.ToString(CultureInfo.CurrentCulture)); //message.IsBodyHtml = true; //client.Send(message); return(true); } return(false); }