Exemplo n.º 1
0
        /// <summary>
        /// This allow a drivers information to be changed
        /// </summary>
        /// <param name="driver"></param>
        /// <returns>"The driver was successfully updated."</returns>
        public IHttpActionResult Put(DriverEdit driver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateDriverService();

            if (!service.UpdateDriver(driver))
            {
                return(InternalServerError());
            }

            return(Ok("The driver was successfully updated."));
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var service = CreateDriverService();
            var detail  = service.GetDriverById(id);
            var model   =
                new DriverEdit
            {
                DriverId      = detail.DriverId,
                FirstName     = detail.FirstName,
                LastName      = detail.LastName,
                Age           = detail.Age,
                LicenseNumber = detail.LicenseNumber,
                SpaceshipMake = detail.SpaceshipMake
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public bool UpdateDriver(DriverEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Drivers
                    .Single(e => e.DriverId == model.DriverId && e.OwnerId == _userId);

                entity.FirstName     = model.FirstName;
                entity.LastName      = model.LastName;
                entity.Age           = model.Age;
                entity.LicenseNumber = model.LicenseNumber;
                entity.SpaceshipMake = model.SpaceshipMake;

                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This allows you to update the drivers information.
        /// </summary>
        /// <param name="model">This is the model of the drivers updated information</param>
        /// <returns></returns>
        public bool UpdateDriver(DriverEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .Drivers
                             .Single(e => e.DriverId == model.DriverId && e.ApplicationUser == _userId);

                entity.DriverFirstName  = model.DriverFirstName;
                entity.DriverLastName   = model.DriverLastName;
                entity.HourlyRate       = model.HourlyRate;
                entity.Location         = model.Location;
                entity.TypeOfBoat       = model.TypeOfBoat;
                entity.DaysAvailable    = model.DaysAvailable;
                entity.MaximumOccupants = model.MaximumOccupants;

                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 5
0
        public ActionResult Edit(int id, DriverEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.DriverId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateDriverService();

            if (service.UpdateDriver(model))
            {
                TempData["SaveResult"] = "Your info has been updated!";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your info could not be changed.");
            return(View(model));
        }
Exemplo n.º 6
0
 virtual public void SelectAll()
 {
     DriverEdit.SelectAll();
 }
Exemplo n.º 7
0
 virtual public void Clear()
 {
     DriverEdit.Clear();
 }
Exemplo n.º 8
0
 virtual public void Append(string txt)
 {
     DriverEdit.Append(txt);
 }
Exemplo n.º 9
0
 virtual public int RemoveIndex(int index)
 {
     return(DriverEdit.RemoveIndex(index));
 }
Exemplo n.º 10
0
 virtual public void Append(object obj)
 {
     DriverEdit.Append(obj);
 }