public void AddDispatcherDashboard(DispatcherDashboard dashboard)
 {
     _data.DispatchersDashboard.Add(dashboard);
     _data.SaveChanges();
 }
        /// <summary>
        /// Adds a new request
        /// </summary>
        /// <param name="startingAddress"></param>
        /// <param name="finishAddress"></param>
        /// <returns></returns>
        public JsonResult CreateRequest(string startingAddress, string finishAddress)
        {
            var userId     = User.Identity.GetUserId();
            var dispatcher = _dispatcherService.GetAll().First(x => x.UserId == userId);
            var company    = _companyService.GetAll().First(x => x.Id == dispatcher.Company.Id);

            var startingLocation = GoogleAPIRequest.GetLocation(startingAddress + " " + company.City);
            var finishLocation   = GoogleAPIRequest.GetLocation(finishAddress + " " + company.City);

            if (startingLocation == null)
            {
                return(Json(new { status = "INVALID STARTING LOCATION" }));
            }
            if (finishLocation == null)
            {
                finishLocation = new Models.Models.Location()
                {
                    Latitude  = 0,
                    Longitude = 0
                };
            }



            var request = new RequestInfo()
            {
                CreatedBy                = CreatedBy.Dispatcher,
                CreatorUserId            = userId,
                RequestStatus            = RequestStatusEnum.NoCarChosen,
                StartingAddress          = startingAddress,
                StartingLocation         = startingLocation,
                FinishAddress            = finishAddress,
                FinishLocation           = finishLocation,
                CreatedDateTime          = DateTime.Now,
                LastModificationDateTime = DateTime.Now,
                Company = company
            };

            _requestService.AddRequestInfo(request);
            var dashboardCell = new DispatcherDashboard()
            {
                DispatcherUserId = userId,
                LastSeen         = DateTime.Now,
                LastSeenStatus   = RequestStatusEnum.NoCarChosen,
                Request          = request
            };

            _dashboardService.AddDispatcherDashboard(dashboardCell);
            var activeRequest = new ActiveRequest()
            {
                AppropriateCar    = null,
                DateTimeChosenCar = DateTime.Now,
                Request           = request
            };

            _requestService.AddActiveRequest(activeRequest);
            var car = _carService.AppropriateCar(startingLocation, dispatcher.Company);

            if (car != null)
            {
                request.RequestStatus        = RequestStatusEnum.NotTaken;
                activeRequest.AppropriateCar = car;
                _requestService.ModifyActiveRequest(activeRequest);
                _requestService.ModifyRequestInfo(request);
            }



            return(Json(new { status = "OK" }));
        }