Beispiel #1
0
        private void editSelectBtn_Click(object sender, EventArgs e)
        {
            string   str_id = Table.SelectedRows[0].Cells[0].Value.ToString();
            ObjectId id     = ObjectId.Parse(str_id);

            if (collectionName == "buses")
            {
                EditBus form = new EditBus(database, collectionName, id);
                form.ShowDialog();

                ShowBuses();
            }
            else if (collectionName == "routes")
            {
                EditRoute form = new EditRoute(database, collectionName, id);
                form.ShowDialog();

                ShowRoutes();
            }
            else if (collectionName == "drivers")
            {
                EditDriver form = new EditDriver(database, collectionName, id);
                form.ShowDialog();

                ShowDrivers();
            }
        }
        public ActionResult <EditDriver> EditDriver(EditDriver model)
        {
            try
            {
                IMapper mapper = EDeliveryProfile.EditDriver();
                var     result = mapper.Map <Driver>(model);

                var userIdClaim = User.FindFirst("MemberId")?.Value;
                var memberId    = int.TryParse(userIdClaim, out var id) ? id : 0;

                EDeliveryDBContext dBContext = new EDeliveryDBContext();
                var deliveryCompanyId        = dBContext.DeliveryCompany.First(o => o.MemberId == memberId).DeliveryCompanyId;
                result.DeliveryCompanyId = deliveryCompanyId;

                _repository.EditDriver(result);

                return(new ObjectResult(new { message = "success", statusCode = HttpStatusCode.OK, response = "Succesfuly edited driver" }));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to edit the driver{ex}");
            }

            return(BadRequest("Failed to edit the driver"));
        }
Beispiel #3
0
        public async Task <IActionResult> Update([FromBody] EditDriver request)
        {
            var result = await _manageDriverService.Update(request);

            if (result == 0)
            {
                return(BadRequest());
            }
            return(Ok());
        }
 public IActionResult Edit(EditDriver editDriver)
 {
     try
     {
         Validator.validateDriver(editDriver);
         DADriver dADriver = new DADriver();
         return(this.OKResponse(dADriver.Edit(_context, editDriver, User.ToAppUser()) == true ? "Updated Successfully" : "Updation Failed"));
     }
     catch (DataValidationException ex)
     {
         return(this.KnowOperationError(ex.Message));
     }
 }
        public async Task <Driver> EditDriver(EditDriver driverForEdit)
        {
            var driver = await _context.Drivers.FindAsync(driverForEdit.Id);

            driver.Name      = driverForEdit.Name;
            driver.Address   = driverForEdit.Address;
            driver.Telephone = driverForEdit.Telephone ?? string.Empty;
            driver.Email     = driverForEdit.Email;
            driver.CompanyId = driverForEdit.CompanyId;

            await _context.SaveChangesAsync();

            return((Driver)_mapper.Map(driver, typeof(Data.Models.Driver), typeof(Driver)));
        }
        public async Task <int> Update(EditDriver request)
        {
            var driver = await _context.Lst_LaiXe.FindAsync(request.id_lg_xe);

            if (driver == null)
            {
                throw new ExceptionId($"Cannot find a driver with id: {request.id_lg_xe}");
            }
            driver.id_lg_xe      = request.id_lg_xe;
            driver.ten_lai_xe    = request.ten_lai_xe;
            driver.gioi_tinh     = request.gioi_tinh;
            driver.so_dien_thoai = request.so_dien_thoai;
            driver.id_RFID       = request.id_RFID;
            driver.nghi_viec     = request.nghi_viec;
            driver.avatar        = request.avatar;
            driver.email         = request.email;
            driver.ten_donvi     = request.ten_donvi;
            return(await _context.SaveChangesAsync());
        }
        public async Task <IHttpActionResult> EditDriver([FromUri] string driverId, [FromBody] EditDriver driverForEdit)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var driver = await _driverBusinessService.GetDriverById(driverId);

            if (driver == null)
            {
                return(this.BadRequest());
            }

            var businessDriverForEdit = _mapper.Map <BusinessService.Models.EditDriver>(driverForEdit);

            businessDriverForEdit.Id = driverId;

            var editedDriver = await _driverBusinessService.EditDriver(businessDriverForEdit);

            var apiDriver = _mapper.Map <EditDriver>(editedDriver);

            return(Ok(apiDriver));
        }
Beispiel #8
0
 public static void validateDriver(EditDriver editDriver)
 {
     if (editDriver.DriverId == 0)
     {
         throw new DataValidationException($"DriverId does not exists");
     }
     if (editDriver.Country == 0)
     {
         throw new DataValidationException($"Country does not exists");
     }
     if (editDriver.DriverArea == 0)
     {
         throw new DataValidationException($"DriverArea does not exists");
     }
     if (editDriver.DriverType == 0)
     {
         throw new DataValidationException($"DriverType does not exists");
     }
     if (editDriver.ZoneId == 0)
     {
         throw new DataValidationException($"ZoneId does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.State))
     {
         throw new DataValidationException($"State does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.ProfilePic))
     {
         throw new DataValidationException($"ProfilePic does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.Password))
     {
         throw new DataValidationException($"Password does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.NationalId))
     {
         throw new DataValidationException($"NationalId does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.LastName))
     {
         throw new DataValidationException($"LastName does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.Address))
     {
         throw new DataValidationException($"Address does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.City))
     {
         throw new DataValidationException($"City does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.Company))
     {
         throw new DataValidationException($"Company does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.ContactNo))
     {
         throw new DataValidationException($"ContactNo does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.Email))
     {
         throw new DataValidationException($"Email does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.Gender))
     {
         throw new DataValidationException($"Gender does not exists");
     }
     if (string.IsNullOrEmpty(editDriver.FirstName))
     {
         throw new DataValidationException($"FirstName does not exists");
     }
 }
Beispiel #9
0
        public async Task <Driver> EditDriver(EditDriver driverForEdit)
        {
            var editedDriver = await _driverDataAccessService.EditDriver(_mapper.Map <DataAccessService.Models.EditDriver>(driverForEdit));

            return(_mapper.Map <Driver>(editedDriver));
        }