public ActionResult Create(TreatmentCreateViewModel model) { if (ModelState.IsValid) { List<Therapist> allThera = new List<Therapist>(); foreach (int id in model.SelectedTherapistId) { Therapist thera = service.TherapistGateway.GetOne(id); allThera.Add(thera); } Treatment treatment = new Treatment { Name = model.Name, Description = model.Description, Price = model.Price, Duration = model.Duration, TreatmentTypeId = model.SelectedTypeId, Therapists = allThera }; service.TreatmentGateway.CreateOne(treatment); return RedirectToAction("Index"); } return View(); }
public void Can_get_duration_time() { Treatment treament1 = new Treatment(); Treatment treament2 = new Treatment(); treament1.Duration = new TimeSpan(0,1,0,0); treament2.Duration = new TimeSpan(0,0,45,0); Booking booking = new Booking(); Assert.AreEqual(new TimeSpan(0,0,0,0),booking.GetDuration()); booking.Treatments.Add(treament1); booking.Treatments.Add(treament2); TimeSpan timeSpan = new TimeSpan(0,1,45,0).Duration(); Assert.AreEqual(timeSpan,booking.GetDuration()); }