public ActionResult DeleteConfirmed(int id) { DrivingPlan drivingPlan = db.DrivingPlans.Find(id); db.DrivingPlans.Remove(drivingPlan); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "drivingID,customerID,employeeID,drivingDate,isDone")] DrivingPlan drivingPlan) { if (ModelState.IsValid) { db.Entry(drivingPlan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.customerID = new SelectList(db.Customers, "customerID", "customerFullName", drivingPlan.customerID); ViewBag.employeeID = new SelectList(db.Employees, "employeeID", "employeeFullName", drivingPlan.employeeID); return(View(drivingPlan)); }
public ActionResult Create([Bind(Include = "drivingID,customerID,employeeID,drivingDate,isDone")] DrivingPlan drivingPlan) { if (ModelState.IsValid) { db.DrivingPlans.Add(drivingPlan); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.customerID = new SelectList(db.Customers, "customerID", "customerFullName", drivingPlan.customerID); ViewBag.employeeID = new SelectList(db.Employees.Where(x => x.User.roleID == 2), "employeeID", "employeeFullName", drivingPlan.employeeID); return(View(drivingPlan)); }
// GET: DrivingPlans/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DrivingPlan drivingPlan = db.DrivingPlans.Find(id); if (drivingPlan == null) { return(HttpNotFound()); } return(View(drivingPlan)); }
public IHttpActionResult GetDrivingPlanDepartures(int lineNumber, DriveType driveType, WeekDays drivePlanDay) { //notificationHub.TimeServerUpdates(); DrivingPlan drivingPlan = unitOfWork.DrivingPlans.GetSpecificDrivingPlan(driveType, drivePlanDay, lineNumber); if (drivingPlan == null) { return(NotFound()); } var departures = drivingPlan.Departures.Split(';'); return(Ok(departures)); }
// GET: DrivingPlans/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DrivingPlan drivingPlan = db.DrivingPlans.Find(id); if (drivingPlan == null) { return(HttpNotFound()); } ViewBag.customerID = new SelectList(db.Customers, "customerID", "customerFullName", drivingPlan.customerID); ViewBag.employeeID = new SelectList(db.Employees, "employeeID", "employeeFullName", drivingPlan.employeeID); return(View(drivingPlan)); }
// GET: DrivingPlans/Create public ActionResult Create(int?employeeID, int?customerID) { ViewBag.customerID = new SelectList(db.Customers, "customerID", "customerFullName"); ViewBag.employeeID = new SelectList(db.Employees.Where(x => x.User.roleID == 2), "employeeID", "employeeFullName"); // Create the empty model to use in case an employee ID or a customer ID is included in the query string param. var model = new DrivingPlan(); // if the employee ID has value, pre-populate the value in the model. if (employeeID.HasValue) { model.employeeID = employeeID.Value; } // if the customer ID has value, pre-populate the value in the model. if (customerID.HasValue) { model.customerID = customerID.Value; } return(View(model)); }
public IHttpActionResult AddDrivingPlan(AddDrivingPlanBindingModel bindingModel) { var lineId = unitOfWork.Drivelines.GetLineByNumber(bindingModel.Number).Id; string departures = ""; foreach (var departure in bindingModel.Departures.OrderBy(d => d, StringComparer.Ordinal)) { departures += departure + ";"; } DrivingPlan drivingPlan = new DrivingPlan() { Type = bindingModel.Type, Day = bindingModel.Day, DrivelineId = lineId, Departures = departures }; unitOfWork.DrivingPlans.Add(drivingPlan); unitOfWork.Complete(); return(Ok()); }
private void InitialDBAdding(WebApp.Persistence.ApplicationDbContext context) { if (!context.Coordinates.Any(c => c.CoordinatesId == 1)) // kada budemo napravili server ovo ce biti nepotrebno { Coordinates c = new Coordinates() { CoordX = 1, CoordY = 1 }; context.Coordinates.Add(c); context.SaveChanges(); } if (!context.Coordinates.Any(c => c.CoordinatesId == 2)) // kada budemo napravili server ovo ce biti nepotrebno { Coordinates c = new Coordinates() { CoordX = 10, CoordY = 10 }; context.Coordinates.Add(c); context.SaveChanges(); } if (!context.DriveLines.Any(d => d.Number == 4)) { var drLine = new Driveline() { Number = 4 }; context.DriveLines.Add(drLine); context.SaveChanges(); } if (!context.DriveLines.Any(d => d.Number == 7)) { var drLine = new Driveline() { Number = 7 }; context.DriveLines.Add(drLine); context.SaveChanges(); } if (!context.DrivingPlans.Any(p => p.Departures.Equals("4: 50 ; 10:30"))) { DrivingPlan drPlan = new DrivingPlan() { Day = Models.Enums.WeekDays.Monday, Type = Models.Enums.DriveType.City, Departures = "4: 50 ; 10:30", DrivelineId = context.DriveLines.Where(l => l.Number == 4).FirstOrDefault().Id }; context.DrivingPlans.Add(drPlan); context.SaveChanges(); } if (!context.DrivingPlans.Any(p => p.Departures.Equals("10:00 ; 11:00 ; 12:00"))) { DrivingPlan drPlan = new DrivingPlan() { Day = Models.Enums.WeekDays.Monday, Type = Models.Enums.DriveType.City, Departures = "10:00 ; 11:00 ; 12:00", DrivelineId = context.DriveLines.Where(l => l.Number == 7).FirstOrDefault().Id }; context.DrivingPlans.Add(drPlan); context.SaveChanges(); } if (!context.Stations.Any(s => s.Name == "FirstStation")) { Station s = new Station() { Name = "FirstStation", Address = "Bulevar Oslobodjenja 1" }; s.CoordinatesId = context.Coordinates.Where(c => c.CoordinatesId == 1).FirstOrDefault().CoordinatesId; context.Stations.Add(s); context.SaveChanges(); } if (!context.Stations.Any(s => s.Name == "SecondStation")) { Station s = new Station() { Name = "SecondStation", Address = "Bulevar Oslobodjenja 10" }; s.CoordinatesId = context.Coordinates.Where(c => c.CoordinatesId == 2).FirstOrDefault().CoordinatesId; context.Stations.Add(s); context.SaveChanges(); } if (!context.Pricelists.Any(p => p.PricelistId == 1)) //necemo po ID-u , ali posto je samo test onda je ok { Pricelist pr = new Pricelist() { ValidFrom = DateTime.Now, ValidUntil = DateTime.Now.AddDays(2) }; context.Pricelists.Add(pr); context.SaveChanges(); } if (!context.PricelistItems.Any(p => p.TicketType == Models.Enums.TicketType.Daily && p.PassengerType == Models.Enums.PassengerType.Regular)) { PricelistItem prI = new PricelistItem() { TicketType = Models.Enums.TicketType.Daily, Price = 200, PassengerType = Models.Enums.PassengerType.Regular }; Pricelist pr = context.Pricelists.Where(p => p.PricelistId == 1).FirstOrDefault(); prI.PricelistId = pr.PricelistId; context.PricelistItems.Add(prI); context.SaveChanges(); pr.PricelistItems.Add(prI); context.PricelistItems.AddOrUpdate(prI); context.SaveChanges(); } if (!context.PassengerTypeCoefficients.Any(p => p.PassengerType == Models.Enums.PassengerType.Regular)) { PassengerTypeCoefficient pas = new PassengerTypeCoefficient() { Coefficient = 1F, PassengerType = Models.Enums.PassengerType.Regular }; context.PassengerTypeCoefficients.Add(pas); context.SaveChanges(); } if (!context.PassengerTypeCoefficients.Any(p => p.PassengerType == Models.Enums.PassengerType.Pensioner)) { PassengerTypeCoefficient pas = new PassengerTypeCoefficient() { Coefficient = 0.9F, PassengerType = Models.Enums.PassengerType.Pensioner }; context.PassengerTypeCoefficients.Add(pas); context.SaveChanges(); } if (!context.PassengerTypeCoefficients.Any(p => p.PassengerType == Models.Enums.PassengerType.Student)) { PassengerTypeCoefficient pas = new PassengerTypeCoefficient() { Coefficient = 0.8F, PassengerType = Models.Enums.PassengerType.Student }; context.PassengerTypeCoefficients.Add(pas); context.SaveChanges(); } }