public IHttpActionResult Put(int idcar, CarPoolModel student) { CarPool existingStudent = MyService.GetById(idcar); if (existingStudent != null) { existingStudent.Title = student.Title; existingStudent.From = student.From; existingStudent.Time = student.Time; existingStudent.To = student.To; existingStudent.Date = student.Date; existingStudent.NbPlaceDispo = student.NbPlaceDispo; existingStudent.Weekly = student.Weekly; existingStudent.Daily = student.Daily; existingStudent.EveryWeekDay = student.EveryWeekDay; existingStudent.Message = student.Message; existingStudent.idKid = 3; existingStudent.UntilDate = student.UntilDate; MyService.Update(existingStudent); MyService.Commit(); } else { return(NotFound()); } return(Ok()); }
// GET api/<controller>/5 public CarPool Get(int id) { CarPool ev = MyService.GetById(id); return(ev); }
// Use this for initialization void Start() { basePath = Application.dataPath + "/../../Testset/Sequence/"; folderName = "testFolder/"; fileName = "testFile.csv"; createFolder(basePath); isReady = false; folderIndex = 1; count = 0; if (imageCapturer == null) { imageCapturer = transform.Find("ImageCapturer").GetComponent <ImageCapturer>(); } if (dataCapturer == null) { dataCapturer = transform.Find("DataCapturer").GetComponent <DataCapturer>(); } if (carPool == null) { carPool = GameObject.Find("CarPool").GetComponent <CarPool>(); } regionCapturer = new RegionCapturer(); screenRect = new Rect(0, 0, imageCapturer.captureWidth, imageCapturer.captureHeight); }
// Use this for initialization void Start() { gameState = FindObjectOfType <GameState>(); spawnCooldown = 2.5f; carPoolLol = GetComponent <CarPool>(); cars = new List <GameObject>(); }
// GET: CarPool/Delete/5 public ActionResult Delete(int id) { CarPool c = sc.GetById(id); sc.Delete(c); sc.Commit(); return(RedirectToAction("MyIndex")); }
/* * Input: trips = [[2,1,5],[3,3,7]], capacity = 4Output: false * * Input: trips = [[2,1,5],[3,3,7]], capacity = 5Output: true * * Input: trips = [[3,2,7],[3,7,9],[8,3,9]], capacity = 11Output: true */ static void Main(string[] args) { int[][] trips = new int[][] { new int[] { 3, 2, 7 }, new int[] { 3, 7, 9 }, new int[] { 8, 3, 9 } }; int capacity = 11; CarPool car = new CarPool(); Console.WriteLine(car.EvaluateTravel(trips, capacity)); Console.ReadKey(); }
public void CarPool_TakeOneTrip_Success() { int[][] trips = new int[][] { new int[] { 3, 2, 7 } }; int capacity = 11; CarPool car = new CarPool(); bool takeTravel = car.EvaluateTravel(trips, capacity); Assert.True(takeTravel); }
public void CarPool_TakeThreeTrips_WithRequiredCapacity_ShouldSucess() { int[][] trips = new int[][] { new int[] { 3, 2, 7 }, new int[] { 3, 7, 9 }, new int[] { 8, 3, 9 } }; int capacity = 11; CarPool car = new CarPool(); bool takeTravel = car.EvaluateTravel(trips, capacity); Assert.True(takeTravel); }
public void CarPool_TakeTwoTrips_WithMoreThanCapacity_ShouldFails() { int[][] trips = new int[][] { new int[] { 2, 1, 5 }, new int[] { 3, 3, 7 } }; int capacity = 4; CarPool car = new CarPool(); bool takeTravel = car.EvaluateTravel(trips, capacity); Assert.False(takeTravel); }
private static List <Occurance> GetOccurances(CarPool carPool, List <WeekDay> weekDays) { List <Occurance> occurances = new List <Occurance>(); foreach (WeekDay weekDay in weekDays) { Occurance occurance = new Occurance { CarPool = carPool, WeekDay = weekDay, DayID = weekDay.ID }; occurances.Add(occurance); } return(occurances); }
public static void AddNewCarPool(CarPoolInfo carPoolInfo, Person person, CarPoolContext carPoolContext) { CarPool carPool = getCarPoolFromInfo(carPoolInfo, person.ID); List <WeekDay> weekDays = getWeekDays(carPoolContext, carPoolInfo.WeekDays); List <Occurance> occurances = GetOccurances(carPool, weekDays); carPool.Occurances = occurances; weekDays.ForEach(w => w.Occurances = occurances.Where(o => o.DayID == w.ID).ToList()); carPoolContext.Database.EnsureCreated(); carPoolContext.CarPools.Add(carPool); carPoolContext.WeekDays.AttachRange(weekDays); carPoolContext.SaveChanges(); }
private static CarPool getCarPoolFromInfo(CarPoolInfo carPoolInfo, int personId) { CarPool carPool = new CarPool { DriverID = personId, CarDescription = carPoolInfo.CarDescription, AdditionalDetails = carPoolInfo.AdditionalDetails, StartLocation = carPoolInfo.StartLocation, EndLocation = carPoolInfo.EndLocation, Seats = carPoolInfo.Seats, ArrivalTime = TimeSpan.Parse(carPoolInfo.Time) }; return(carPool); }
// GET: CarPool/Edit/5 public ActionResult Edit(int?id, bool hidden_field1 = false, bool hidden_field2 = false, bool hidden_field3 = false) { var userId = (int)Session["idu"]; String nom = ps.GetById(userId).nom; String prenom = ps.GetById(userId).prenom; String mail = ps.GetById(userId).email; ViewBag.home = mail; ViewBag.nom = nom; ViewBag.prenom = prenom; var CarPoolToUpdate = db.CarPools.Find(id); if (hidden_field1) { CarPoolToUpdate.Daily = true; } else { CarPoolToUpdate.Daily = false; } if (hidden_field2) { CarPoolToUpdate.EveryWeekDay = true; } else { CarPoolToUpdate.EveryWeekDay = false; } if (hidden_field3) { CarPoolToUpdate.Weekly = true; } else { CarPoolToUpdate.Weekly = false; } CarPool collection = sc.GetById((long)id); CarPoolModel c = new CarPoolModel(); c.Id = collection.Id; c.Title = collection.Title; c.From = collection.From; c.To = collection.To; c.Time = collection.Time; c.Date = collection.Date; c.Message = collection.Message; c.NbPlaceDispo = collection.NbPlaceDispo; c.idKid = collection.idKid; List <Kid> query = ServicePar.GetMany().ToList(); //var userId = (int)Session["idu"]; // var kidss = db.Kids; // var query = kidss.Where(z => z.idParent == userId).Select(z=>z.FirstName).ToList(); //ViewBag.MyKid = new SelectList(query, "IdKid", "FirstName"); var kidss = db.Kids; ViewBag.Kidsss = kidss.Where(z => z.idParent == userId).Select(m => new SelectListItem { Value = m.IdKid.ToString(), Text = m.FirstName }); return(View(c)); }
public ActionResult create(CarPoolModel collection, bool hidden_field1 = false, bool hidden_field2 = false, bool hidden_field3 = false) { ICarPoolService sc = new CarPoolService(); CarPool c = new CarPool(); DateTime date = DateTime.Parse(c.Date.ToString()); DateTime today = DateTime.Today; if (ModelState.IsValid) { if (hidden_field1) { c.Daily = true; } else { c.Daily = false; } if (hidden_field2) { c.EveryWeekDay = true; } else { c.EveryWeekDay = false; } if (hidden_field3) { c.Weekly = true; } else { c.Weekly = false; } c.UntilDate = collection.UntilDate; c.Others = c.Daily || c.EveryWeekDay || c.Weekly ? false : true; c.idParent = (int)Session["idu"]; c.Id = collection.Id; c.Title = collection.Title; c.From = collection.From; c.To = collection.To; c.Time = collection.Time; c.Date = collection.Date; c.Message = collection.Message; c.NbPlaceDispo = collection.NbPlaceDispo; c.idKid = collection.idKid; sc.Add(c); sc.Commit(); return(RedirectToAction("MyIndex")); } else { return(View()); } }
private static CarPoolInfo getCarPoolInfoBase(CarPoolContext carPoolContext, PersonContext personContext, CarPool carPool) { CarPoolInfo carPoolInfo = new CarPoolInfo { Driver = getDriverName(personContext, carPool.DriverID), CarDescription = carPool.CarDescription, AdditionalDetails = carPool.AdditionalDetails, StartLocation = carPool.StartLocation, EndLocation = carPool.EndLocation, Seats = carPool.Seats, Time = carPool.ArrivalTime.ToString(), WeekDays = getWeekDays(carPoolContext, carPool.ID) }; return(carPoolInfo); }
public void MoveToPool(CarPool pool) { transform.SetParent(pool.transform); gameObject.SetActive(false); }