public void PhoneNumber_Check() { string number1 = "0634340324"; string number2 = "063434"; string number3 = "sadsa"; Assert.IsTrue(BuisnessLogic.checkPhoneNumber(number1)); Assert.IsFalse(BuisnessLogic.checkPhoneNumber(number2)); Assert.IsFalse(BuisnessLogic.checkPhoneNumber(number3)); }
public void TestMethod1() { var mockobj = new Mock <IDataAccess>(); mockobj.Setup(x => x.GetData(1)).Returns("Hello1"); var mockobj1 = new BuisnessLogic(mockobj.Object); var data = mockobj1.GetData(1); Assert.AreEqual(data, "Hello1"); }
public ActionResult Create([Bind(Include = "AppointmentID,DoctorID,Date,TimeBlockHelper,Time")] AppointmentModel appointment) { //Add userID appointment.UserID = User.Identity.GetUserId(); //Verify Time if (appointment.TimeBlockHelper == "DONT") { ModelState.AddModelError("", "No Appointments Available for " + appointment.Date.ToShortDateString()); } else { //Set Time appointment.Time = DateTime.Parse(appointment.TimeBlockHelper); //CheckWorkingHours DateTime start = appointment.Date.Add(appointment.Time.TimeOfDay); DateTime end = (appointment.Date.Add(appointment.Time.TimeOfDay)).AddMinutes(double.Parse(db.Administrations.Find(1).Value)); if (!(BuisnessLogic.IsInWorkingHours(start, end))) { ModelState.AddModelError("", "Doctor Working Hours are from " + int.Parse(db.Administrations.Find(2).Value) + " to " + int.Parse(db.Administrations.Find(3).Value)); } //Check Appointment Clash string check = BuisnessLogic.ValidateNoAppoinmentClash(appointment); if (check != "") { ModelState.AddModelError("", check); } } //Continue Normally if (ModelState.IsValid) { db.Appointments.Add(appointment); db.SaveChanges(); return(RedirectToAction("Details", new { Controller = "RegisteredUsers", Action = "Details" })); } //Fill Neccessary ViewBags ViewBag.DoctorID = new SelectList(db.Doctors.Where(x => x.DisableNewAppointments == false), "ID", "Name", appointment.DoctorID); ViewBag.TimeBlockHelper = new SelectList(String.Empty); return(View(appointment)); }
public static void Main(string[] args) { IBL _bl = new BuisnessLogic(Settings.Default.DataBaseAdress, Settings.Default.DataBaseName); char c = 'h'; while (true) { if (c == 'm') { foreach (IManufacturer manuf in _bl.GetAllManufs()) { Console.WriteLine(manuf.Id.ToString() + "):\t" + manuf.Nazwa); } } else if (c == 'p') { foreach (IProduct product in _bl.GetAllProducts()) { Console.WriteLine(product.Id.ToString() + "):\t" + product.Nazwa + ";\t--Stan=" + product.Stan.ToString()); } } else if (c == 'x') { break; } else if (c == 'q') { break; } else if (c == 'h') { Console.WriteLine(@"Press 'm' to show Manufacturers"); Console.WriteLine(@"Press 'p' to show Products"); Console.WriteLine(@"Press 'h' to show help"); Console.WriteLine(@"Press 'q' or 'x' to exit"); } c = Console.ReadKey().KeyChar; Console.WriteLine(""); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (phoneNumber.Text == "Enter phone number" || from.Text == "Enter from point" || to.Text == "Enter destination point") { warning1.Content = "Fill all fields."; } else if (!BuisnessLogic.checkPhoneNumber(phoneNumber.Text)) { warning1.Content = "Number should look like: " + Environment.NewLine + "0XXXXXXXXX"; } else { afterOrder.Content = ""; warning1.Content = ""; orderBtn.Visibility = Visibility.Visible; phone.Content = "Your phone number: " + phoneNumber.Text; fromp.Content = "From: " + from.Text; top.Content = "To: " + to.Text; typep.Content = "Type of car: " + type.Text; price.Content = "Price: " + priceS + " $"; } }
public ActionResult Edit([Bind(Include = "AppointmentID,DoctorID,Date,TimeBlockHelper,Available")] AppointmentModel appointment) { //Verify Time if (appointment.TimeBlockHelper == "DONT") { ModelState.AddModelError("", "No Appointments Available for " + appointment.Date.ToShortDateString()); } else { //Set Time appointment.Time = DateTime.Parse(appointment.TimeBlockHelper); //Check WorkingHours DateTime start = new DateTime(appointment.Date.Year, appointment.Date.Month, appointment.Date.Day, appointment.Time.Hour, appointment.Time.Minute, appointment.Time.Second); DateTime end = new DateTime(appointment.Date.Year, appointment.Date.Month, appointment.Date.Day, appointment.Time.Hour, appointment.Time.Minute, appointment.Time.Second).AddMinutes(double.Parse(db.Administrations.Find(1).Value)); if (!BuisnessLogic.IsInWorkingHours(start, end)) { ModelState.AddModelError("", "Doctor Working Hours are from " + int.Parse(db.Administrations.Find(2).Value) + " to " + int.Parse(db.Administrations.Find(3).Value)); } } //Continue if (ModelState.IsValid) { db.Entry(appointment).State = EntityState.Modified; db.Entry(appointment).Property(u => u.UserID).IsModified = false; db.SaveChanges(); if (User.IsInRole("Admin")) { return(RedirectToAction("Index")); } return(RedirectToAction("Details", new { Controller = "RegisteredUsers", Action = "Details" })); } ViewBag.TimeBlockHelper = new SelectList(String.Empty); ViewBag.DoctorID = new SelectList(db.Doctors.Where(x => x.DisableNewAppointments == false), "ID", "Name", appointment.DoctorID); return(View(appointment)); }
public JsonResult GetAvailableAppointments(int docID, DateTime date) { List <SelectListItem> resultlist = BuisnessLogic.AvailableAppointments(docID, date); return(Json(resultlist)); }