Esempio n. 1
0
 /// <summary>
 /// Invoked when this page is about to be displayed in a Frame.
 /// </summary>
 /// <param name="e">Event data that describes how this page was reached.
 /// This parameter is typically used to configure the page.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     activeQuoteViewModel = e.Parameter as ActiveQuoteViewModel;
     dc = new DriverController(activeQuoteViewModel.q.Id);
     this.DataContext = dc.DriverViewModel;
     driverViewModel = dc.DriverViewModel;
 }
        public async Task <ActionResult> Driver()
        {
            return(await Task.Run <ActionResult>(() =>
            {
                var getCRMDriverByConditionRequest = new GetDriverByConditionRequest();
                getCRMDriverByConditionRequest.SearchCondition = new DriverSearchCondition();
                getCRMDriverByConditionRequest.PageSize = BasicFramework.Common.Constants.PAGESIZE;
                getCRMDriverByConditionRequest.PageIndex = 0;

                DriverViewModel vm = new DriverViewModel();
                var getCRMDriverByConditionResponse = new DriverService().GetCRMDriverBykeyword(getCRMDriverByConditionRequest);

                if (getCRMDriverByConditionResponse.IsSuccess)
                {
                    vm.DriverCollection = getCRMDriverByConditionResponse.Result.DriverCollection;
                    vm.PageIndex = getCRMDriverByConditionResponse.Result.PageIndex;
                    vm.PageCount = getCRMDriverByConditionResponse.Result.PageCount;
                }
                else
                {
                    throw new Exception(getCRMDriverByConditionResponse.Exception.Message);
                }
                return View(vm);
            }));
        }
        public async Task <ActionResult> GetShipperMappingDriverInfoBySIDandkeyWord(string id, string keyword, int?pageIndex)
        {
            return(await Task.Run <ActionResult>(() =>
            {
                var getCRMDriverByConditionRequest = new GetDriverByConditionRequest();
                getCRMDriverByConditionRequest.SearchCondition = new DriverSearchCondition();
                getCRMDriverByConditionRequest.keyword = keyword;
                getCRMDriverByConditionRequest.PageSize = BasicFramework.Common.Constants.PAGESIZE;
                getCRMDriverByConditionRequest.PageIndex = pageIndex ?? 0;

                DriverViewModel vm = new DriverViewModel();

                var getCRMDriverByConditionResponse = new DriverService().GetShipperMappingDriverInfoBySIDandkeyWord(id, getCRMDriverByConditionRequest);

                if (getCRMDriverByConditionResponse.IsSuccess)
                {
                    vm.DriverCollection = getCRMDriverByConditionResponse.Result.DriverCollection;
                    vm.PageIndex = getCRMDriverByConditionResponse.Result.PageIndex;
                    vm.PageCount = getCRMDriverByConditionResponse.Result.PageCount;
                }
                else
                {
                    throw new Exception(getCRMDriverByConditionResponse.Exception.Message);
                }

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                serializer.RegisterConverters(new JavaScriptConverter[] { new DateTimeConverter() });
                string js = serializer.Serialize(vm);
                return Json(js, JsonRequestBehavior.AllowGet);
            }));
        }
Esempio n. 4
0
        public ActionResult Edit(int id, DriverViewModel model)
        {
            try
            {
                Domain.Driver.Driver driver = _driverService.GetDriverById(id);
                driver.Name                       = model.Name;
                driver.NIC                        = model.NIC;
                driver.DateOfBirth                = model.DateOfBirth;
                driver.ResidentAddress            = model.ResidentAddress;
                driver.ContactNumber1             = model.ContactNumber1;
                driver.ContactNumber2             = model.ContactNumber2;
                driver.EPFNumber                  = model.EPFNumber;
                driver.DLNumber                   = model.DLNumber;
                driver.DateOfExpiryLicense        = model.DateOfExpiryLicense;
                driver.DefensiveLicenseNumber     = model.DefensiveLicenseNumber;
                driver.DefensiveLicenseExpiryDate = model.DefensiveLicenseExpiryDate;
                driver.DriverGrade                = model.DriverGrade;
                driver.StartDateOfWork            = model.StartDateOfWork;
                driver.PeriodOfService            = model.PeriodOfService;
                driver.BasicSalary                = model.BasicSalary;
                driver.MinimumSalary              = model.MinimumSalary;
                driver.PoliceReportExpiryDate     = model.PoliceReportExpiryDate;
                _driverService.SaveDriver(driver);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
        public void ShouldRentCarIfRequirementsAreFulfilled()
        {
            var driverId        = Guid.NewGuid();
            var driverViewModel = new DriverViewModel
            {
                Id           = driverId,
                DriverStatus = DriverStatus.Active
            };
            var carId = Guid.NewGuid();
            var car   = new CarViewModel()
            {
                Id = carId
            };
            var sut = new RentCarViewModel(_carServiceMock, _rentalServiceMock, _carViewModelMapperMock,
                                           _rentalViewModelMapperMock, _messengerServiceMock)
            {
                CurrentDriver = driverViewModel, SelectedCar = car
            };

            sut.RentCarCommand.Execute(null);

            _rentalServiceMock.Received().TakeCar(Arg.Any <Guid>(), carId, driverId, Arg.Any <DateTime>());
            _rentalViewModelMapperMock.Received().Map(Arg.Any <RentalDTO>());
            _messengerServiceMock.Received().Send(Arg.Is <RentalViewModelMessage>(message => message.MessageType == RentalViewModelMessageType.StartRental));
            _messengerServiceMock.Received().Send(Arg.Is <NotificationMessage>(message => message.Notification == "Start Car Rental"));
            Assert.Null(sut.ErrorString);
        }
Esempio n. 6
0
        public ActionResult AddDriver(DriverViewModel model)
        {
            if (ModelState.IsValid)
            {
                UserBO newDriver = new UserBO
                {
                    UserName         = model.EmployeeId.Trim(),
                    Email            = model.Email.Trim(),
                    FullName         = model.Fullname.Trim(),
                    LockoutEnabled   = true,
                    EmailConfirmed   = true,
                    Audit            = new Domain.Entity.Audit(),
                    HasAcceptedTerms = true,
                };
                var result = UserManager.Create(newDriver, "password1");

                if (result == IdentityResult.Success)
                {
                    DriverBO driver = new DriverBO(newDriver.Id)
                    {
                        EmployeeId = model.EmployeeId.Trim(),
                        Audit      = new Domain.Entity.Audit()
                    };
                    windsor.busManager.Add(driver);
                    var addToRoleResult = UserManager.AddToRole(newDriver.Id, "Driver");
                }
                return(RedirectToAction("Drivers"));
            }
            return(View(model));
        }
Esempio n. 7
0
        public void Create(DriverViewModel driverVM)
        {
            var driver = new Driver
            {
                Name  = driverVM.Name,
                Notes = driverVM.Notes,
                Rate  = driverVM.Rate
            };

            var deliveries = new List <Delivery>(driverVM.Deliveries?.Count ?? 0);

            if (driverVM.Deliveries != null)
            {
                foreach (var deliveryVM in driverVM.Deliveries)
                {
                    var delivery = _deliveriesService.GetEntityById(deliveryVM.Id);
                    deliveries.Add(delivery);
                }
            }


            driver.Deliveries = deliveries;

            _service.CreateEntity(driver);
        }
Esempio n. 8
0
        public ActionResult Added(DriverViewModel driverVm)
        {
            if (ModelState.IsValid)
            {
                Employee employee = new Employee();
                employee.Name          = driverVm.Name;
                employee.ContactNo     = driverVm.ContactNo;
                employee.Email         = driverVm.Email;
                employee.Address1      = driverVm.Address1;
                employee.Address2      = driverVm.Address2;
                employee.LicenceNo     = driverVm.LicenceNo;
                employee.IsDriver      = driverVm.IsDriver;
                employee.DepartmentId  = driverVm.DepartmentId;
                employee.DesignationId = driverVm.DesignationId;
                employee.DivisionId    = driverVm.DivisionId;
                employee.DistrictId    = driverVm.DistrictId;
                employee.ThanaId       = driverVm.ThanaId;

                bool isSaved = _employeeManager.Add(employee);
                if (isSaved)
                {
                    TempData["msg"] = "Driver Save Successfully.";
                    return(RedirectToAction("Index", "Driver"));
                }
                TempData["msg"] = "Driver Not Saved Successfully.";
                return(RedirectToAction("Added"));
            }
            return(View());
        }
Esempio n. 9
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var             department  = _departmentManager.GetAll();
            var             designation = _designationManager.GetAll();
            var             division    = _divisionManager.GetAll();
            var             district    = _districtManager.GetAll();
            var             thana       = _thanaManager.GetAll();
            Employee        driver      = _employeeManager.GetById((int)id);
            DriverViewModel driverVm    = new DriverViewModel()
            {
                Id          = driver.Id,
                Name        = driver.Name,
                ContactNo   = driver.ContactNo,
                Email       = driver.Email,
                Address1    = driver.Address1,
                Address2    = driver.Address2,
                LicenceNo   = driver.LicenceNo,
                Department  = department.Where(x => x.Id == driver.DepartmentId).FirstOrDefault(),
                Designation = designation.Where(x => x.Id == driver.DesignationId).FirstOrDefault(),
                Division    = division.Where(x => x.Id == driver.DivisionId).FirstOrDefault(),
                District    = district.Where(x => x.Id == driver.DistrictId).FirstOrDefault(),
                Thana       = thana.Where(x => x.Id == driver.ThanaId).FirstOrDefault(),
                ImagePath   = driver.ImagePath
            };

            return(View(driverVm));
        }
Esempio n. 10
0
        public async Task <IActionResult> Edit(int id, DriverViewModel model)
        {
            if (id != model.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(model);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DriverExists(model.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Esempio n. 11
0
        public ActionResult DriverList()
        {
            var driverList  = _employeeManager.Get(c => c.IsDriver == true && c.IsDeleted == false);
            var department  = _departmentManager.GetAll();
            var designation = _designationManager.GetAll();

            List <DriverViewModel> AllDriverList = new List <DriverViewModel>();

            foreach (var emploeedata in driverList)
            {
                var driverVm = new DriverViewModel();
                driverVm.Id          = emploeedata.Id;
                driverVm.Name        = emploeedata.Name;
                driverVm.ContactNo   = emploeedata.ContactNo;
                driverVm.Email       = emploeedata.Email;
                driverVm.Address1    = emploeedata.Address1;
                driverVm.Address2    = emploeedata.Address2;
                driverVm.LicenceNo   = emploeedata.LicenceNo;
                driverVm.IsDriver    = emploeedata.IsDriver;
                driverVm.Department  = department.Where(x => x.Id == emploeedata.DepartmentId).FirstOrDefault();
                driverVm.Designation = designation.Where(x => x.Id == emploeedata.DesignationId).FirstOrDefault();

                AllDriverList.Add(driverVm);
            }
            ViewBag.TotalDriver = driverList.Count;
            return(View(AllDriverList));
        }
Esempio n. 12
0
        public ActionResult Edit(string ID)
        {
            DriverViewModel driverDetail   = new DriverViewModel();
            int             Id             = JsonConvert.DeserializeObject <int>(ID);
            var             dbDriverDetail = GBContext.DriverDetails.Where(m => m.DriverDetailID == Id).FirstOrDefault();

            driverDetail.DriverDetailID            = dbDriverDetail.DriverDetailID;
            driverDetail.FirstName                 = dbDriverDetail.FirstName;
            driverDetail.LastName                  = dbDriverDetail.LastName;
            driverDetail.PhoneNumber               = dbDriverDetail.PhoneNumber;
            driverDetail.Pincode                   = dbDriverDetail.Pincode;
            driverDetail.LicenceType               = dbDriverDetail.LicenceTypeID;
            driverDetail.Status                    = dbDriverDetail.DriverStatusID;
            driverDetail.LicenceNo                 = dbDriverDetail.LicenceNo;
            driverDetail.ExpectedSalary            = dbDriverDetail.ExpectedSalary;
            driverDetail.Ola                       = dbDriverDetail.Ola;
            driverDetail.Uber                      = dbDriverDetail.Uber;
            driverDetail.CityID                    = dbDriverDetail.CityID;
            driverDetail.User                      = dbDriverDetail.User;
            driverDetail.FollowUpOn                = String.Format("{0:dd/MM/yyyy}", dbDriverDetail.FollowUpOn).Replace("-", "/") ?? String.Empty;
            driverDetail.FollowUpNotes             = dbDriverDetail.FollowUpNotes;
            driverDetail.NextFollowUp              = String.Format("{0:dd/MM/yyyy}", dbDriverDetail.NextFollowUp).Replace("-", "/") ?? String.Empty;
            driverDetail.DriverDetailsActivityLogs = dbDriverDetail.DriverDetailsActivityLogs.Where(x => x.FollowUpOn != null).OrderByDescending(x => x.FollowUpOn).ToList();
            return(View(driverDetail));
        }
Esempio n. 13
0
        public HttpResponseMessage Create(HttpRequestMessage request, DriverViewModel driverVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var newDriver = new Driver();
                    newDriver.UpdateDriver(driverVm);
                    newDriver.CreatedDate = DateTime.Now;

                    _driverService.Add(newDriver);
                    _driverService.Save();

                    var responseData = Mapper.Map <Driver, DriverViewModel>(newDriver);
                    response = request.CreateResponse(HttpStatusCode.Created, responseData);
                }

                return response;
            }));
        }
Esempio n. 14
0
        public async Task <IActionResult> OnGetAsync(long?id, string returnUrl)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ReturnUrl = returnUrl;
            var driver = await _context.Drivers.SingleOrDefaultAsync(m => m.Id == id);

            if (driver == null)
            {
                return(NotFound());
            }
            var townlist = (await _townService.GetAvailableTownsEagerAsync(HttpContext.User));

            ViewData["TownList"] = new SelectList(townlist, "Id", "Name");
            if (townlist.Any())
            {
                var groups = (await _groupService.ListGroupsForTownEagerAsync(HttpContext.User, townlist.First().Id));
                ViewData["GroupList"] = new SelectList(groups, "Id", "Name");
            }

            DriverItem = new DriverViewModel(driver);

            return(Page());
        }
Esempio n. 15
0
        public ActionResult Details(int Id)
        {
            CompanyId = Convert.ToInt32(Session["CompanyId"]);
            try
            {
                driverViewModel.Id        = Id;
                driverViewModel.CompanyId = CompanyId;

                var result = webServices.Post(driverViewModel, "Driver/Edit");

                if (result.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    if (result.Data != "[]")
                    {
                        driverViewModel = (new JavaScriptSerializer().Deserialize <DriverViewModel>(result.Data.ToString()));
                    }
                }

                return(View(driverViewModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 16
0
        public ActionResult Index()
        {
            var department  = _departmentManager.GetAll();
            var designation = _designationManager.GetAll();
            var driver      = _employeeManager.Get(c => c.IsDriver == true && c.IsDeleted == false);
            var division    = _divisionManager.GetAll();
            var district    = _districtManager.GetAll();
            var thana       = _thanaManager.GetAll();

            List <DriverViewModel> driverViewList = new List <DriverViewModel>();

            foreach (var driverdata in driver)
            {
                var driverVm = new DriverViewModel();
                driverVm.Id          = driverdata.Id;
                driverVm.Name        = driverdata.Name;
                driverVm.ContactNo   = driverdata.ContactNo;
                driverVm.Email       = driverdata.Email;
                driverVm.Address1    = driverdata.Address1;
                driverVm.Address2    = driverdata.Address2;
                driverVm.LicenceNo   = driverdata.LicenceNo;
                driverVm.Department  = department.Where(x => x.Id == driverdata.DepartmentId).FirstOrDefault();
                driverVm.Designation = designation.Where(x => x.Id == driverdata.DesignationId).FirstOrDefault();
                driverVm.Division    = division.Where(x => x.Id == driverdata.DivisionId).FirstOrDefault();
                driverVm.District    = district.Where(x => x.Id == driverdata.DistrictId).FirstOrDefault();
                driverVm.Thana       = thana.Where(x => x.Id == driverdata.ThanaId).FirstOrDefault();

                driverViewList.Add(driverVm);
            }
            return(View(driverViewList));
        }
Esempio n. 17
0
        public ActionResult Edit(int Id, int CompId = 0)
        {
            CompanyId = Convert.ToInt32(Session["CompanyId"]);
            try
            {
                if (CompId < 1)
                {
                    CompanyId          = Convert.ToInt32(Session["CompanyId"]);
                    ViewBag.LayoutName = "~/Views/Shared/_layout.cshtml";
                }
                else
                {
                    CompanyId          = CompId;
                    ViewBag.LayoutName = "~/Views/Shared/_layoutAdmin.cshtml";
                }

                driverViewModel.Id        = Id;
                driverViewModel.CompanyId = CompanyId;
                var result = webServices.Post(driverViewModel, "Driver/Edit/");

                if (result.StatusCode == System.Net.HttpStatusCode.Accepted)
                {
                    if (result.Data != "[]")
                    {
                        driverViewModel = (new JavaScriptSerializer().Deserialize <DriverViewModel>(result.Data.ToString()));
                    }
                }

                return(View(driverViewModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 18
0
        // GET: Driver/Added
        public ActionResult Added()
        {
            var department  = _departmentManager.GetAll();
            var designation = _designationManager.GetAll();
            var division    = _divisionManager.GetAll();
            var district    = _districtManager.GetAll();
            var thana       = _thanaManager.GetAll();

            DriverViewModel driverVm = new DriverViewModel
            {
                Departments  = department,
                Designations = designation,
                Divisions    = division,
                Districts    = district,
                Thanas       = thana,
                IsDriver     = true
            };

            ViewBag.districtDropDown = new SelectListItem[] { new SelectListItem()
                                                              {
                                                                  Value = "", Text = "Select..."
                                                              } };
            ViewBag.DistrictId = new SelectListItem[] { new SelectListItem()
                                                        {
                                                            Value = "", Text = "Select..."
                                                        } };
            ViewBag.ThanaId = new SelectListItem[] { new SelectListItem()
                                                     {
                                                         Value = "", Text = "Select..."
                                                     } };

            return(View(driverVm));
        }
Esempio n. 19
0
        public void Update(DriverViewModel driver)
        {
            var existedDriver = _service.GetEntityById(driver.Id);

            existedDriver.Name  = driver.Name;
            existedDriver.Notes = driver.Notes;
            existedDriver.Rate  = driver.Rate;

            var deliveries = new List <Delivery>(driver.Deliveries?.Count ?? 0);

            if (driver.Deliveries != null)
            {
                foreach (var deliveryVM in driver.Deliveries)
                {
                    var delivery = _deliveriesService.GetEntityById(deliveryVM.Id);

                    if (delivery != null)
                    {
                        deliveries.Add(delivery);
                    }
                }
            }

            existedDriver.Deliveries = deliveries;
            _service.UpdateEntity(existedDriver);
        }
 //Get Employee Create (Driver)
 public ActionResult CreateDriver()
 {
     try
     {
         ViewBag.DepartmentId   = new SelectList(_departmentManager.GetAll(), "Id", "Name");
         ViewBag.DesignationId  = new SelectList(_designationManager.GetAll(), "Id", "Title");
         ViewBag.OrganizationId = new SelectList(_organizationManager.GetAll(), "Id", "Name");
         ViewBag.EmployeeTypeId = new SelectList(_employeeTypeManager.GetAll(), "Id", "Type", 2);
         DriverViewModel driverViewModel = new DriverViewModel();
         driverViewModel.DivisionList = (List <Division>)_divisionManager.GetAllDivisions();
         ViewBag.DistrictDropDown     = new SelectList(new[] { new SelectListItem()
                                                               {
                                                                   Value = "", Text = "Select District"
                                                               } }, "Value", "Text");
         ViewBag.UpazilaDropDown = new SelectList(new[] { new SelectListItem()
                                                          {
                                                              Value = "", Text = "Select Upazila"
                                                          } }, "Value", "Text");
         return(View(driverViewModel));
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "Employees", "CreateDriver")));
     }
 }
Esempio n. 21
0
        public async Task <ActionResult> Driver(DriverViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
 // GET: Driver/Edit/5
 public ActionResult EditDriver(int?id)
 {
     try
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Employee employee = _employeeManager.FindById((int)id);
         if (employee == null)
         {
             return(HttpNotFound());
         }
         ViewBag.DepartmentId   = new SelectList(_departmentManager.GetAll(), "Id", "Name", employee.DepartmentId);
         ViewBag.DesignationId  = new SelectList(_designationManager.GetAll(), "Id", "Title", employee.DesignationId);
         ViewBag.OrganizationId = new SelectList(_organizationManager.GetAll(), "Id", "Name", employee.OrganizationId);
         ViewBag.EmployeeTypeId = new SelectList(_employeeTypeManager.GetAll(), "Id", "Type", employee.EmployeeTypeId);
         DriverViewModel driverViewModel = Mapper.Map <DriverViewModel>(employee);
         driverViewModel.DivisionList = (List <Division>)_divisionManager.GetAllDivisions();
         ViewBag.DistrictDropDown     = new SelectList(new[] { new SelectListItem()
                                                               {
                                                                   Value = "", Text = "Select District"
                                                               } }, "Value", "Text");
         ViewBag.UpazilaDropDown = new SelectList(new[] { new SelectListItem()
                                                          {
                                                              Value = "", Text = "Select Upazila"
                                                          } }, "Value", "Text");
         return(View(driverViewModel));
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "Employees", "EditDriver")));
     }
 }
Esempio n. 23
0
        public ActionResult Create(DriverViewModel model, string button)
        {
            try
            {
                if (_driverService.IsDriverExists(model.EPFNumber, model.NIC))
                {
                    Driver driver = new Driver();
                    driver = Mapper.Map <Driver>(model);
                    _driverService.SaveDriver(driver);

                    if (button.Equals("SAVE DRIVER"))
                    {
                        return(RedirectToAction("Index"));
                    }
                    ModelState.Clear();
                    ViewData["Success"] = "Successfully Added.";
                }
                else
                {
                    ModelState.AddModelError("", "Driver employee Id or NIC number already exists");
                }
                return(View());
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Esempio n. 24
0
        public ActionResult DriverAllOnline(DriverViewModel driverViewModel)
        {
            try
            {
                CompanyId = Convert.ToInt32(Session["CompanyId"]);
                if (driverViewModel.Name == "Driver")
                {
                    var DriverInfo = webServices.Post(new DriverViewModel(), "AWFDriver/DriverAllOnline/" + CompanyId);
                    if (DriverInfo.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        var OnlineDriverList = (new JavaScriptSerializer().Deserialize <List <DriverViewModel> >(DriverInfo.Data.ToString()));
                        OnlineDriverList.Insert(0, new DriverViewModel()
                        {
                            Id = 0, Name = "Select Driver"
                        });

                        return(Json(OnlineDriverList, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    var siteViewModels = new List <SiteViewModel>();
                    CompanyId = Convert.ToInt32(Session["CompanyId"]);

                    PagingParameterModel pagingParameterModel = new PagingParameterModel
                    {
                        pageNumber = 1,
                        _pageSize  = 1,
                        CompanyId  = CompanyId,
                        PageSize   = 100,
                    };
                    var SiteList = webServices.Post(pagingParameterModel, "Site/All");
                    if (SiteList.StatusCode == System.Net.HttpStatusCode.Accepted)
                    {
                        siteViewModels = (new JavaScriptSerializer().Deserialize <List <SiteViewModel> >(SiteList.Data.ToString()));
                    }
                    siteViewModels.Insert(0, new SiteViewModel()
                    {
                        Id = 0, SiteName = "Select Site"
                    });

                    var OnlineDriverList = new List <DriverViewModel>();

                    foreach (var item in siteViewModels)
                    {
                        OnlineDriverList.Add(new DriverViewModel()
                        {
                            Id   = item.Id,
                            Name = item.SiteName
                        });
                    }
                    return(Json(OnlineDriverList, JsonRequestBehavior.AllowGet));
                }
                return(Json("failed", JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json("failed", JsonRequestBehavior.AllowGet));
            }
        }
        public void ShouldSendRentalViewModelMessageWithContinueRentalPropertyIfDriverHasActiveRental()
        {
            //assign
            var driverId        = Guid.NewGuid();
            var driverViewModel = new DriverViewModel()
            {
                Id = driverId
            };
            var activeRentalDto = new RentalDTO();

            _rentalServiceMock.GetActiveRentalForDriver(driverId).Returns(activeRentalDto);

            var activeRentalViewModel = new RentalViewModel();

            _rentalViewModelMapperMock.Map(activeRentalDto).Returns(activeRentalViewModel);

            //act
            var sut = new RentCarViewModel(_carServiceMock, _rentalServiceMock, _carViewModelMapperMock, _rentalViewModelMapperMock, _messengerServiceMock);

            sut.AssignLoggedInDriver(driverViewModel);

            //assert
            _messengerServiceMock.Received().Send(Arg.Is <RentalViewModelMessage>(message => message.RentalViewModel == activeRentalViewModel && message.MessageType == RentalViewModelMessageType.ContinueRental));
            _messengerServiceMock.Received().Send(Arg.Is <NotificationMessage>(message => message.Notification == "Start Car Rental"));
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                PhotoURL.Text = "";
                DriverViewModel driver = DriverLogic.GetCurrentDriver();
                Currentdriver.Photo = driver.Photo;
                if (driver.Photo != null)
                {
                    borderImage.BorderBrush = Brushes.White;
                    ImageDriver.Source      = ImageLogic.ImageFromByte(driver.Photo);
                }

                Name.Text              = driver.Name;
                Phone.Text             = driver.Telephone;
                Mail.Text              = driver.Email;
                Passport.Text          = driver.Passport;
                DateBirth.SelectedDate = driver.DateBirth;
                Address.Text           = driver.FullAddress;
                AddressLife.Text       = driver.AddressLife;
                PostCode.Text          = driver.PostCode.ToString();
                Company.Text           = driver.Company;
                JobName.Text           = driver.JobName;
                Expirience.Text        = driver.DrivingExperience.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 通过shipperID查询该车辆是由哪位司机驾驶
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <ActionResult> ShipperMappingDriverBySID(int id)
        {
            return(await Task.Run <ActionResult>(() =>
            {
                var getCRMVehicleByConditionRequest = new GetDriverByConditionRequest();
                getCRMVehicleByConditionRequest.SearchCondition = new DriverSearchCondition();

                getCRMVehicleByConditionRequest.keyword = id.ToString();
                getCRMVehicleByConditionRequest.PageSize = BasicFramework.Common.Constants.PAGESIZE;
                getCRMVehicleByConditionRequest.PageIndex = 0;

                DriverViewModel vm = new DriverViewModel();
                var getCRMDriverByConditionResponse = new DriverService().GetShippingMappingDriverSID(getCRMVehicleByConditionRequest);

                if (getCRMDriverByConditionResponse.IsSuccess)
                {
                    vm.DriverCollection = getCRMDriverByConditionResponse.Result.DriverCollection;
                    vm.PageIndex = getCRMDriverByConditionResponse.Result.PageIndex;
                    vm.PageCount = getCRMDriverByConditionResponse.Result.PageCount;
                }
                else
                {
                    throw new Exception(getCRMDriverByConditionResponse.Exception.Message);
                }

                ViewData["id"] = id;

                return View(vm);
            }));
        }
Esempio n. 28
0
        public void CreateDriver(DriverViewModel driverViewModel)
        {
            var driver = Mapper.Map <DriverViewModel, Driver_M>(driverViewModel);

            _driverRepository.Add(driver);
            SaveDriver();
        }
Esempio n. 29
0
        public static DriverModel ToDriverModel(DriverViewModel driver)
        {
            string last     = string.Empty;
            var    fullName = driver.FullName.Split(' ');
            var    begin    = DateTime.Now.AddDays(-driver.BeginJob);

            if (fullName.Length > 1)
            {
                last = fullName[1];
            }
            else
            {
                last = fullName[0];
            }


            return(new DriverModel()
            {
                Adress = driver.Adress,
                Email = driver.Email,
                FirstName = fullName[0],
                LastName = last,
                BeginJob = begin,
                LicenceID = driver.LicenceID,
                PhoneNumber = driver.PhoneNumber,
                LastEyeCheck = driver.LastEyeCheck
            });
        }
Esempio n. 30
0
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var driver = await _context.Drivers
                         .Include(t => t.Vehicles).ThenInclude(v => v.Town)
                         .Include(t => t.Vehicles).ThenInclude(v => v.Group)
                         .Include(t => t.Town)
                         .Include(t => t.Group)
                         .Include(t => t.AvatarImage)
                         .Include(t => t.LicenseImage)
                         .Include(t => t.ExtraImage1)
                         .Include(t => t.ExtraImage2)
                         .Include(t => t.ExtraImage3)
                         .SingleOrDefaultAsync(m => m.Id == id);

            if (driver == null)
            {
                return(NotFound());
            }
            DriverItem = new DriverViewModel(driver);
            Vehicles   = driver.Vehicles.Select(t => new VehicleListViewModel(t)).ToList();
            return(Page());
        }