Ejemplo n.º 1
0
        public override void SaveForm()
        {
            DriverModel driverModel = (DriverModel)currentControl.GetFieldValues();

            _driverService.SaveDriver(driverModel);
            base.SaveForm();
        }
Ejemplo n.º 2
0
        public virtual IActionResult Create(DriverModel model, bool continueEditing)
        {
            if (!permissionService.Authorize(StandardPermissionProvider.ManageDrivers))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var entity = model.ToEntity <Driver>();
                driverService.Insert(entity);

                // activity log
                customerActivityService.InsertActivity("AddNewDriver",
                                                       string.Format(localizationService.GetResource("ActivityLog.AddNewDriver"), entity.Id),
                                                       entity);

                SuccessNotification(localizationService.GetResource("Admin.Logistics.Driver.Added"));

                if (!continueEditing)
                {
                    return(RedirectToAction("List"));
                }

                SaveSelectedTabName();

                return(RedirectToAction("Edit", new { id = entity.Id }));
            }

            model = driverFactory.PrepareModel(model, null, true);

            return(View(model));
        }
Ejemplo n.º 3
0
        private void btnDeleteDriver_Click(object sender, EventArgs e)
        {
            if (_driverWhenEdited == null)
            {
                MessageBox.Show("Choose dreiver first");
                return;
            }

            for (int i = 0; i < cmbEditAllDrivers.Items.Count; i++)
            {
                if ((cmbEditAllDrivers.Items[i] as ComboDriver).Driver.Id == _driverWhenEdited.Id)
                {
                    cmbEditAllDrivers.Items.Remove(cmbEditAllDrivers.Items[i]);
                }
            }
            pbxEditDrivers.Image           = new Bitmap(10, 10);
            txtChangeDriverCarLicense.Text = string.Empty;
            txtChangeDriverFirstname.Text  = string.Empty;
            txtChangeDriverLastName.Text   = string.Empty;
            cmbChangeDriverCars.Text       = string.Empty;
            cmbChangeDriverRoutes1.Text    = string.Empty;
            cmbChangeDriverRoutes2.Text    = string.Empty;
            pnlLongNumberChangeDriverIDCertificate.Number = "0";

            _connector.DeleteDocument <DriverModel>("Drivers", _driverWhenEdited.Id);
            _driverWhenEdited = null;
        }
Ejemplo n.º 4
0
        public async Task <Tuple <string, ObservableCollection <object> > > DriversStandings()
        {
            var standingsCollection = new ObservableCollection <object>();

            this.driverModel = await this.GetModelData(this.driverModel, this.apiURL);

            var heading =
                $"{this.driverModel.MRData.StandingsTable.StandingsLists[0].season} Formula 1 Season - {this.driverModel.MRData.StandingsTable.StandingsLists[0].round} Rounds";

            foreach (var driver in this.driverModel.MRData.StandingsTable.StandingsLists[0].DriverStandings)
            {
                standingsCollection.Add(new DriversStandingsCollection
                {
                    Position = int.Parse(driver.position),
                    Driver   =
                        $"{driver.Driver.givenName[0]}. {driver.Driver.familyName} ({(driver.Driver.permanentNumber != null ? driver.Driver.permanentNumber : "--")})",
                    Points      = float.Parse(driver.points),
                    Wins        = int.Parse(driver.wins),
                    Constructor = driver.Constructors[0].name,
                    Nationality = driver.Driver.nationality
                });
            }

            return(new Tuple <string, ObservableCollection <object> >(heading, standingsCollection));
        }
Ejemplo n.º 5
0
        public ActionResult Create(DriverModel driverModel)
        {
            try
            {
                driverModel.createdBy = Convert.ToInt32(Session["UserId"]);

                var DriverViewModelList = webServices.Post(driverModel, "Vehicle/DirectSaleVehicleAndDriverAdd");
                if (DriverViewModelList.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    driverModel = (new JavaScriptSerializer().Deserialize <DriverModel>(DriverViewModelList.Data.ToString()));



                    TempData["driverModel"] = driverModel;

                    //return View("DirectsaleOrderAdd", driverModel);
                    return(RedirectToAction(nameof(DirectsaleOrderAdd)));
                }
                return(View());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 6
0
        public ActionResult WebPage(DriverModel Model)
        {
            Boolean New = (Request.Form).AllKeys[(Request.Form).AllKeys.GetUpperBound(0)].Trim() == "savenew" ? true : false;

            try
            {
                if (Model.SEQ_ID > 0)
                {
                    Model.MODIFIED_BY = Convert.ToInt32(Session["USERID"]);
                    Model.MODIFIED_ON = DateTime.Now;
                    new Brill.Helper().UpdateModelInDatabase(Model);
                }
                else
                {
                    Model.CREATED_BY = Convert.ToInt32(Session["USERID"]);
                    Model.CREATED_ON = DateTime.Now;
                    new Brill.Helper().InsertModelInDatabase(Model);
                }

                if (New)
                {
                    return(RedirectToAction("WebPage", "Driver"));
                }
                else
                {
                    return(RedirectToAction("Index", "Driver"));
                }
            }
            catch (Exception ex)
            {
                Helper();
                ViewBag.Message = ex.Message;
                return(View(Model));
            }
        }
Ejemplo n.º 7
0
 public static void AddDriver(DriverModel newDriver)
 {
     newDriver.Telephone = "+7" + CheckPhone(newDriver.Telephone);
     newDriver.Email     = CheckEmail(newDriver.Email);
     DbContext.db.Drivers.Add(newDriver);
     DbContext.db.SaveChanges();
 }
Ejemplo n.º 8
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value == null)
            {
                return("Unassigned");
            }

            // Get driver name
            DriverModel driverModel = value as DriverModel;

            if (driverModel != null)
            {
                return(driverModel.DriverName);
            }

            // If we are here, we have a BusModel object, so let's convert
            BusModel busModel = value as BusModel;

            if (busModel != null)
            {
                return(busModel.BusTag);
            }

            return(value);
        }
Ejemplo n.º 9
0
        public void Delete(DriverModel driverModel)
        {
            try
            {
                if (ValidateDelete(driverModel))
                {
                    return;
                }

                Driver driver = dbContext.Drivers.Where(x => x.Id == driverModel.Id).FirstOrDefault();

                if (driver == null)
                {
                    base.HandleError(driverModel, CommonLayer.LookUps.ErrorType.Critical, null, Resources.NotFound);
                    return;
                }

                dbContext.Drivers.Remove(driver);

                base.SaveChanges();

                driverModel.AddSuccess(Resources.DriverDeletedSuccessfully, LookUps.SuccessType.Full);
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException)
            {
                base.HandleError(driverModel, CommonLayer.LookUps.ErrorType.Business, null, Resources.RefrenceDeleteError);
                base.UndoUpdates();
            }
            catch (Exception ex)
            {
                base.HandleError(driverModel, CommonLayer.LookUps.ErrorType.Exception, ex);
                base.UndoUpdates();
            }
        }
Ejemplo n.º 10
0
        public HttpResponseMessage tripEmployeelist([FromBody] DriverModel driverm)
        {
            var re      = Request;
            var headers = re.Headers;

            if (headers.Contains("token"))
            {
                token = headers.GetValues("token").First();
            }

            var result = Authtoken.checkToken(token);

            if (result == true)
            {
                dt = objDriverDl.GetemployeesForTrip(driverm);



                var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK,
                                                                  new ResponseModel()
                {
                    message = "ok successful", output = dt, statuscode = Convert.ToInt16(HttpStatusCode.OK)
                });
                return(resp);
            }

            else
            {
                var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel()
                {
                    message = "UnAuthorized", statuscode = Convert.ToInt16(HttpStatusCode.OK), error = true
                });
                return(resp);
            }
        }
Ejemplo n.º 11
0
        public DriversEditViewModel()
        {
            driverService = (App.Current as App).Container.GetService <IDriverService>();

            // Cast object to DriverModel and assign
            driverModelToEdit = driverService.GetDriverToEdit() as DriverModel;

            // Set driver name for label
            DriverName = driverModelToEdit.DriverName;

            PublishEditDriverCommand = new RelayCommand(
                async() =>
            {
                var messageDialog = new MessageDialog("Are you sure you want to commit these changes?", "Accept Driver Changes");
                messageDialog.Commands.Add(new UICommand("Yes", null));
                messageDialog.Commands.Add(new UICommand("No", null));
                messageDialog.DefaultCommandIndex = 0;
                messageDialog.CancelCommandIndex  = 1;
                var cmd = await messageDialog.ShowAsync();

                if (cmd.Label == "Yes")
                {
                    driverService.EditDriver(DriverName, DriverFirstName, DriverLastName, DriverNumber);
                }

                DriverFirstName = "";
                DriverLastName  = "";

                NavigationService.Navigate(typeof(DriversPage));
            });
        }
Ejemplo n.º 12
0
        public ActionResult DirectsaleOrderAdd()
        {
            DriverModel driverModel = new DriverModel();

            driverModel = TempData["driverModel"] as DriverModel;

            //if (driverModel.TraficPlateNumber == null)
            //{
            //    return RedirectToAction(nameof(DirectSaleCreate));
            //}
            //else
            //{

            var productList = webServices.Post(new ProductViewModel(), "Product/All");

            if (productList.StatusCode == System.Net.HttpStatusCode.Accepted)
            {
                productViewModels = (new JavaScriptSerializer().Deserialize <List <ProductViewModel> >(productList.Data.ToString()));
            }
            ViewBag.productViewModels = productViewModels;

            TempData.Keep();

            return(View(driverModel));
            //}
        }
Ejemplo n.º 13
0
        internal DriverModel GetDriverById(int id)
        {
            var context = EntityContextSingleton.Instance;
            var driver  = context.Driver.First(dr => dr.Id.Equals(id));

            return(DriverModel.CreateFrom(driver));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> Put(int DriverId, DriverModel model)
        {
            try
            {
                var Driver = await _Repository.GetDriverByIdAsync(DriverId);

                if (Driver == null)
                {
                    return(NotFound());
                }

                var Driverw = _mapper.Map <Driver>(model);

                _Repository.Update(Driverw);
                if (await _Repository.SaveChangesAsync())
                {
                    return(Created($"/api/Driver/{Driverw.Id}", _mapper.Map(model, Driverw)));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco Dados Falhou"));
            }

            return(BadRequest());
        }
Ejemplo n.º 15
0
        public void Edit(DriverModel driverModel)
        {
            try
            {
                Driver driver = dbContext.Drivers.Where(x => x.Id == driverModel.Id).FirstOrDefault();

                if (driver == null)
                {
                    base.HandleError(driverModel, CommonLayer.LookUps.ErrorType.Critical, null, Resources.NotFound);
                    return;
                }

                if (Validate(driverModel))
                {
                    return;
                }

                DriverMapper.Map(dbContext, driverModel, driver);

                base.SaveChanges();

                driverModel.AddSuccess(Resources.DriverUpdatedSuccessfully, LookUps.SuccessType.Full);
            }
            catch (Exception ex)
            {
                base.HandleError(driverModel, CommonLayer.LookUps.ErrorType.Exception, ex);
                base.UndoUpdates();
            }
        }
Ejemplo n.º 16
0
        public void GetDriverByNameEmptyName()
        {
            IDriver result = null;
            //Arrange
            var driverDataProvider = Substitute.For <IDriverDataProvider>();

            driverDataProvider.GetByName(Arg.Any <string>()).Returns(x => null);

            //Act
            var driverListViewModel = new DriverModel(driverDataProvider);

            try
            {
                result = driverListViewModel.GetDriverByName(string.Empty);
                Assert.Fail("Exception should be thrown");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is ArgumentException);
                Assert.AreEqual(ex.Message, "Name Cannot Be Empty");
            }

            //Assert
            Assert.IsNull(result);
        }
Ejemplo n.º 17
0
        public HttpResponseMessage updatePresentLocation([FromBody] DriverModel driverm)
        {
            var re      = Request;
            var headers = re.Headers;

            if (headers.Contains("token"))
            {
                token = headers.GetValues("token").First();
            }

            var result = Authtoken.checkToken(token);

            if (result == true)
            {
                objDriverDl.updatePresentlocation(driverm);


                var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK,
                                                                  new ResponseModel()
                {
                    message = "your Location Updated Successfully", output = dt, statuscode = Convert.ToInt16(HttpStatusCode.OK)
                });
                return(resp);
            }

            else
            {
                var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel()
                {
                    message = "UnAuthorized", statuscode = Convert.ToInt16(HttpStatusCode.OK), error = true
                });
                return(resp);
            }
        }
Ejemplo n.º 18
0
        public override void EditForm(object id)
        {
            int         driverId = (int)id;
            DriverModel driver   = driverId == 0 ? new DriverModel() : _driverService.GetDriver(driverId);

            currentControl.PopulateData(driver);
            base.EditForm(id);
        }
Ejemplo n.º 19
0
        public ActionResult RedirectToEditDriver(DriverModel driver)
        {
            var driverGroupList = driverGroupAdapter.SelectAllDriverGroups();

            driver.GroupsList = new SelectList(driverGroupList, "Id", "Name");

            return(View("~/Views/Admin/Edit/EditDriver.cshtml", driver));
        }
Ejemplo n.º 20
0
        public override void PopulateData(object data)
        {
            DriverModel model = (DriverModel)data;

            hdnDriverId.Text  = model.Id.ToString();
            txtSurname.Text   = model.Surname;
            txtFirstName.Text = model.Name;
        }
Ejemplo n.º 21
0
        public ActionResult Delete(string ID)
        {
            DriverModel Model = new DriverModel();

            Model.SEQ_ID = Convert.ToInt32(ID);
            new Brill.Helper().DeleteModelInDatabase(Model);
            return(RedirectToAction("Index", "Driver"));
        }
        private void HookModelToView(View view, DriverModel driverModel, ViewGroup upperView)
        {
            view.LayoutParameters = MapHelper.GetLayoutParams(upperView, _model.Map.MapService.Map, driverModel.CurrentLocation);
            ImageView driverIconImageView = view.FindViewById <ImageView>(Resource.Id.driverIconImageView);

            driverIconImageView.Hover += (sender, e) => ShowDriverInfoPopupWindow(driverModel, view);
            driverIconImageView.Click += (sender, e) => ShowDriverInfoPopupWindow(driverModel, view);
        }
Ejemplo n.º 23
0
        private bool Validate(DriverModel driverModel)
        {
            if (dbContext.Drivers.Any(x => x.Name == driverModel.Name && x.Id != driverModel.Id.ToString()))
            {
                base.HandleError(driverModel, CommonLayer.LookUps.ErrorType.Business, null, string.Format(Resources.AlreadyExists, driverModel.GetDisplayName(x => x.Name)), driverModel.nameof(x => x.Name));
            }

            return(driverModel.HasErrorByType());
        }
Ejemplo n.º 24
0
 public void DeleteDriver(DriverModel model)
 {
     try
     {
         string request = JsonConvert.SerializeObject(model);
         TCPConnection.Instance.SendData("DC" + request);
     }
     catch { }
 }
Ejemplo n.º 25
0
        public async Task <IActionResult> PutDriverModel([FromRoute] int id, [FromBody] DriverModel driverModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != driverModel.DriverId)
            {
                return(BadRequest());
            }

            var oldDriverModel = _context.DriverModels.Find(id);

            oldDriverModel.DriverName    = driverModel.DriverName;
            oldDriverModel.PreviousCache = oldDriverModel.CurrentCache;
            oldDriverModel.CurrentCache  = driverModel.CurrentCache - 72;
            oldDriverModel.Status        = driverModel.Status;
            oldDriverModel.ServerId      = driverModel.ServerId;

            if (oldDriverModel.Status == "Auto")
            {
                if (oldDriverModel.CurrentCache > oldDriverModel.PreviousCache)
                {
                    oldDriverModel.Status = "Rising";
                }
                else if (oldDriverModel.CurrentCache < oldDriverModel.PreviousCache)
                {
                    oldDriverModel.Status = "Lowering";
                }
                else
                {
                    oldDriverModel.Status = "Unchanged";
                }
            }

            _context.Update(oldDriverModel);
            //_context.Entry(driverModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DriverModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 26
0
        public HttpResponseMessage RegisterDriver([FromBody] DriverModel driverm)
        {
            string name  = driverm.name;
            string email = driverm.email;
            int    age   = driverm.age;

            //cmd.CommandType = CommandType.StoredProcedure;
            //cmd.Parameters.AddWithValue("@name", driverm.name);
            //cmd.Parameters.AddWithValue("@email", driverm.email);
            //cmd.Parameters.AddWithValue("@age", driverm.age);
            //cmd.Parameters.AddWithValue("@emergencyContact", driverm.emergencyContact);
            //cmd.Parameters.AddWithValue("@panno", driverm.panno);
            //cmd.Parameters.AddWithValue("@aadharno", driverm.aadharNo);
            //cmd.Parameters.AddWithValue("@experience", driverm.experience);
            //cmd.Parameters.AddWithValue("@currentAddr", driverm.currentAddr);
            //cmd.Parameters.AddWithValue("@permanentAaddr", driverm.permanentAaddr);
            //cmd.Parameters.AddWithValue("@licenceno", driverm.licenceno);
            //cmd.Parameters.AddWithValue("@fromdateTodate", driverm.fromdateTodate);

            //cmd.Parameters.AddWithValue("@transportCompany", driverm.transportCompany);


            //cmd.Parameters.AddWithValue("@vehicleno", driverm.vehicleno);
            //cmd.Parameters.AddWithValue("@profilePic", driverm.profilePic);
            //cmd.Parameters.AddWithValue("@bloodGroup", driverm.bloodGroup);

            //cmd.Parameters.AddWithValue("@eyeSight", driverm.eyeSight);
            //cmd.Parameters.AddWithValue("@breathTest", driverm.breathTest);

            //cmd.Parameters.AddWithValue("@lifeInsurance", driverm.lifeInsurance);



            //cmd.Parameters.AddWithValue("@isSmoke", driverm.isSmoke);
            //cmd.Parameters.AddWithValue("@physicalInjuries", driverm.physicalInjuries);
            //cmd.Parameters.AddWithValue("@otherhealthIssues", driverm.otherhealthIssues);
            //cmd.Parameters.AddWithValue("@driverDeviceid", driverm.deviceId);

            //cmd.Parameters.AddWithValue("@status",1);



            con.Open();
            SqlCommand cmd4 = new SqlCommand("insert into driver(name,email,age)values('" + name + "','" + email + "','" + age + "')", con);

            cmd4.ExecuteNonQuery();
            con.Close();

            var resp = Request.CreateResponse <LoginResponseModel>(HttpStatusCode.OK,
                                                                   new LoginResponseModel()
            {
                message = "driver Register sucessfully", statuscode = Convert.ToInt16(HttpStatusCode.OK)
            });

            return(resp);
        }
Ejemplo n.º 27
0
        public ActionResult Index()
        {
            DriverModel Model = new DriverModel();

            Model.ACTIVE = true;
            List <DriverModel> ModelList = new Brill.Helper().SelectModelListFromDatabase(Model);

            Helper();
            return(View(ModelList));
        }
Ejemplo n.º 28
0
 public void PrepareDriverModel(DriverModel driverModel)
 {
     try
     {
     }
     catch (Exception ex)
     {
         base.HandleError(driverModel, CommonLayer.LookUps.ErrorType.Critical, ex);
     }
 }
Ejemplo n.º 29
0
 public async Task CreateDriverAsync(DriverModel driver)
 {
     using (var db = HibernateSession.GetCurrentSession()) {
         using (var tx = db.BeginTransaction()) {
             db.Save(driver);
             tx.Commit();
             db.Flush();
         }
     }
 }
Ejemplo n.º 30
0
        public static void updateDriver(DriverModel model)
        {
            string queryString = "UPDATE Driver SET ";

            queryString += "passengers = '" + String.Join(",", model.passengers) + "'," +
                           "PlacesTaken = " + model.PlacesTaken +
                           " WHERE Id = " + model.Id;

            sqlhandler.execSQLStatement(queryString);
        }
Ejemplo n.º 31
0
 private void GetAllDriver()
 {
     _drivers.Clear();
     try
     {
         vmsLinqDataContext datacontext = new vmsLinqDataContext();
         var query = from d in datacontext.Drivers
                      select d;
         DriverModel model;
         foreach (Driver data in query)
         {
             model = new DriverModel();
             model.ID = data.ID;
             model.FirstName = data.FirstName;
             model.LastName = data.LastName;
             model.BirthDay = Convert.ToDateTime(data.BirthDay);
             _drivers.Add(model);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }