Exemple #1
0
        public async Task <ActionResult> Save(RouteViewModel model)
        {
            using (RouteServiceClient client = new RouteServiceClient())
            {
                Route obj = new Route()
                {
                    Key         = model.Name,
                    Status      = model.Status,
                    RouteType   = model.RouteType,
                    Description = model.Description,
                    Editor      = User.Identity.Name,
                    EditTime    = DateTime.Now,
                    CreateTime  = DateTime.Now,
                    Creator     = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(FMMResources.StringResource.Route_Save_Success
                                                , model.Name);
                }
                return(Json(rst));
            }
        }
Exemple #2
0
        public async Task <ActionResult> SaveModify(RouteViewModel model)
        {
            using (RouteServiceClient client = new RouteServiceClient())
            {
                MethodReturnResult <Route> result = await client.GetAsync(model.Name);

                if (result.Code == 0)
                {
                    result.Data.Status      = model.Status;
                    result.Data.RouteType   = model.RouteType;
                    result.Data.Description = model.Description;
                    result.Data.Editor      = User.Identity.Name;
                    result.Data.EditTime    = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(FMMResources.StringResource.Route_SaveModify_Success
                                                    , model.Name);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
        public IViewComponentResult Invoke(RouteViewModel model = null)
        {
            if (model != null)
            {
                if (signInManager.IsSignedIn(UserClaimsPrincipal))
                {
                    if (model.Author.Id == userManager.GetUserId(UserClaimsPrincipal) ||
                        User.IsInRole("Administrator"))
                    {
                        return(View("Author", model));
                    }

                    return(View("UserRoutesDetails", model));
                }

                return(View("GuestRoutesDetails"));
            }

            if (signInManager.IsSignedIn(UserClaimsPrincipal))
            {
                return(View("UserRoutesIndex"));
            }

            return(View("GuestRoutesIndex"));
        }
Exemple #4
0
        public async Task <IActionResult> DeleteComment(string commentId, string routeId)
        {
            try
            {
                await this.routeService.DeleteCommentAsync(commentId);

                logger.LogInformation(
                    string.Format(SetLog.Delete,
                                  CurrentUser.UserName,
                                  CurrentController,
                                  $"StoryCommentFor-{routeId}"
                                  ));

                RouteViewModel route = routeService.GetRouteByIdAsViewModel(routeId);
                return(PartialView("_RouteComments", route.Comments));
            }
            catch (System.Exception e)
            {
                logger.LogError(string.Format(SetLog.Error,
                                              CurrentUser.UserName,
                                              CurrentController,
                                              e.Message));

                AddDangerNotification(Notifications.Fail);

                return(null);
            }
        }
Exemple #5
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> AddRoute([FromBody] RouteViewModel route)
        {
            if (ModelState.IsValid)
            {
                string userID = _userManager.GetUserId(User);
                SingleModelResponse <Route> routeResponse = await Task.Run(() => _context.SaveRoute(route, userID));

                if (routeResponse.DidError == true || routeResponse == null)
                {
                    if (routeResponse == null)
                    {
                        return(View("Error"));
                    }
                    Error er = new Error(routeResponse.ErrorMessage);
                    return(View("Error", er));
                }
                var CookieOption = new CookieOptions();
                CookieOption.Expires  = DateTime.Now.AddMinutes(1);
                CookieOption.HttpOnly = true;

                string source = "Add";
                //set cookie
                HttpContext.Response.Cookies.Append("SourcePageMap", source, CookieOption);
                string url = Url.Action("SavedRoutes", "Map");
                return(Json(new { Url = url }));
            }
            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors);
                Debug.WriteLine("Errors found: " + errors + "\nEnd Errors found");
                return(BadRequest(ModelState));
            }
        }
Exemple #6
0
        //[ValidateAntiForgeryToken]
        public IActionResult Edit([FromBody] RouteViewModel route)
        {
            if (ModelState.IsValid)
            {
                route.UserID = _userManager.GetUserId(User);
                SingleModelResponse <Route> routeResponse = _context.UpdateRoute(route);
                if (routeResponse.DidError == true || routeResponse == null)
                {
                    if (routeResponse == null)
                    {
                        return(View("Error"));
                    }
                    Error er = new Error(routeResponse.ErrorMessage);
                    return(View("Error"));
                }
                var CookieOption = new CookieOptions();
                CookieOption.Expires  = DateTime.Now.AddMinutes(1);
                CookieOption.HttpOnly = true;

                string source = "Edit";
                //set cookie
                HttpContext.Response.Cookies.Append("SourcePageMap", source, CookieOption);
                return(RedirectToAction("SavedRoutes"));
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
Exemple #7
0
        public IActionResult UpdateRoute(Route route)
        {
            //To check if the form is valide
            //true: do some more validation
            //false: Redirect to the index page with the model
            if (ModelState.IsValid)
            {
                //Check if the FlightDuration not null and ntot 0
                if ((route.FlightDuration != null) && route.FlightDuration != 0)
                {
                    //Update the route data
                    routeDAL.UpdateData(route.RouteID, (double)route.FlightDuration);
                }
                //Redirect to index action
                return(RedirectToAction("Index"));
            }
            else
            {
                //The model
                RouteViewModel routeViewModel = new RouteViewModel
                {
                    RouteList      = routeDAL.getAllRoutes(),
                    SearchOption   = Route.GetTableList(),
                    TicketSize     = bookingDAL.GetAllBooking().Count(),
                    FlightSchedule = new FlightSchedule(),
                    CreateRoute    = route,
                    ShowAddPop     = false,
                    ShowRoutePop   = true
                };


                //Redirect to the index view with view model
                return(View("Index", routeViewModel));
            }
        }
Exemple #8
0
        public async Task <ActionResult> Copy(string key)
        {
            using (RouteServiceClient client = new RouteServiceClient())
            {
                MethodReturnResult <Route> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    RouteViewModel model = new RouteViewModel()
                    {
                        Name        = result.Data.Key,
                        RouteType   = result.Data.RouteType,
                        Description = result.Data.Description,
                        Status      = result.Data.Status,
                        Creator     = User.Identity.Name,
                        CreateTime  = DateTime.Now,
                        Editor      = User.Identity.Name,
                        EditTime    = DateTime.Now,
                        ParentName  = key
                    };
                    return(PartialView("_CopyPartial", model));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                    return(PartialView("_CopyPartial"));
                }
            }
        }
Exemple #9
0
        public void UpdateRoute(RouteViewModel route_vm)
        {
            // Конфигурирование AutoMapper
            //Mapper.Initialize(cfg => cfg.CreateMap<RouteViewModel, Route>());
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <RouteViewModel, Route>();
                cfg.CreateMap <TripViewModel, Trip>();
                cfg.CreateMap <CityViewModel, City>();
            });
            var mapper = config.CreateMapper();
            // Отображение объекта CityViewModel на City
            //var route_m = Mapper.Map<Route>(route_vm);
            var route_m = mapper.Map <Route>(route_vm);
            //database.Routes.Update(route_m);
            //database.Save();

            Route route = new Route
            {
                CityDepartId = route_m.CityDepart.CityId,
                CityArrId    = route_m.CityArr.CityId,
                Kilometres   = route_m.Kilometres,
                RouteId      = route_m.RouteId,
                CityArr      = route_m.CityArr,
                CityDepart   = route_m.CityDepart
                               //CityArr = route_vm.CityArr
                               ////CityDepart=
            };

            database.Routes.Update(route);
            database.Save();
        }
Exemple #10
0
        public OkResult Post([FromBody] RouteViewModel route)
        {
            RouteEntity entity = mapper.Map <RouteEntity>(route);

            this.routeService.AddRoute(entity);
            return(Ok());
        }
Exemple #11
0
        public SingleModelResponse <Route> SaveRoute(RouteViewModel mapRoute, string userId)
        {
            string            MapUrl         = MapUri + "AddRoute?userId=" + userId;
            List <Checkpoint> newCheckPoints = new List <Checkpoint>();

            foreach (CheckpointViewModel check in mapRoute.Checkpoints)
            {
                Checkpoint checkPoint = new Checkpoint();
                checkPoint.Latitude  = check.Latitude;
                checkPoint.Longitude = check.Longitude;
                newCheckPoints.Add(checkPoint);
            }

            var newRoute = new Route
            {
                UserID     = mapRoute.UserID,
                Title      = mapRoute.Title,
                Distance   = mapRoute.TotalDistance,
                Location   = mapRoute.Location,
                Checkpoint = newCheckPoints
            };
            var createdRoute = PostContent(MapUrl, newRoute);

            return(createdRoute);
        }
Exemple #12
0
        public ActionResult CreateRoute(RouteViewModel inputData)
        {
            using (HomecareDBEntities db = new HomecareDBEntities())
            {
                var caretakerIdToDb = db.Caretakers
                                      .FirstOrDefault(ci => ci.caretaker_name == inputData.caretaker)
                                      .id_caretaker;

                var addressIdToDb = db.Patients
                                    .FirstOrDefault(ai => ai.cpr == inputData.patientCpr).fk_address_patient;

                var arrivalToDb = inputData.date.TimeOfDay;

                var dateToDb = inputData.date.Date;

                var route = new Route
                {
                    arrival            = arrivalToDb,
                    date               = dateToDb,
                    fk_caretaker_route = caretakerIdToDb,
                    fk_address_route   = addressIdToDb
                };
                db.Routes.Add(route);
                db.SaveChanges();
            };

            return(View());
        }
        //this will identify the user role and redirect him/her to the right path
        public static RouteViewModel IdentifyRouteByUserID(string userId)
        {
            var rvm = new RouteViewModel();

            if (!string.IsNullOrEmpty(userId))
            {
                using (var ctx = new App.Data.Models.CubeBox_DBContext())
                {
                    var userRole = ctx.AspNetUserRoles.Where(i => i.UserId == userId);
                    var result   = userRole.FirstOrDefault();
                    if (result != null)
                    {
                        var role = ctx.AspNetRoles.SingleOrDefault(r => r.Id == result.RoleId);
                        if (role != null)
                        {
                            if (role.Name.Contains("Administrator"))
                            {
                                rvm.user = "******";
                                rvm.path = "Index";
                                return(rvm);
                            }
                        }
                    }
                    else
                    {
                        rvm.user = "******";
                        rvm.path = "Index";
                        return(rvm);
                    }
                }
            }
            rvm.user = "******";
            rvm.path = "Index";
            return(rvm);
        }
        public ActionResult RouteDetails(string routeName)
        {
            var route = db.Routes.ToList().Find(x => x.RouteName == routeName);

            Session["rid"] = route.RouteId;

            List <RouteViewModel> gd = new List <RouteViewModel>();
            var list = (from u in db.Ranks
                        join r in db.Routes on u.RankId equals r.RankId
                        join rm in db.Prices on r.RouteId equals rm.RouteId
                        select new
            {
                u.RankName,
                r.RouteName,
                rm.pricevalue
            }).ToList();

            foreach (var it in list)
            {
                RouteViewModel gdd = new RouteViewModel();
                gdd.RankName   = it.RankName;
                gdd.RouteName  = it.RouteName;
                gdd.Pricevalue = it.pricevalue;

                gd.Add(gdd);
            }


            return(View(gd));
        }
Exemple #15
0
        public async Task <ActionResult> Destination(int id, int centerNumber, string routeNumber, DateTime sourceStopPlannedDeliveryDateTime)
        {
            if (id != 0)
            {
                var model = new RouteViewModel(await RouteService.GetByRouteIdAndCenterNumberAndRouteNumberAsync(id, centerNumber, routeNumber));
                return(Json(JsonConvert.SerializeObject(model), JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (string.IsNullOrEmpty(routeNumber))
                {
                    return(null);
                }

                var weekending = Dates.GetWeekending(sourceStopPlannedDeliveryDateTime.Date).AddHours(12);
                var startWeek  = weekending.AddDays(-6);
                var criteria   = new SearchRoute
                {
                    CenterNumber    = centerNumber,
                    RouteNumber     = routeNumber,
                    FilterStartDate = startWeek,
                    FilterEndDate   = weekending
                };

                var routes = await RouteService.SearchAsync(criteria);

                if (routes == null || !routes.Any() || routes.Count() == 0)
                {
                    return(null);
                }

                var model = new RouteViewModel(routes.FirstOrDefault());
                return(Json(JsonConvert.SerializeObject(model), JsonRequestBehavior.AllowGet));
            }
        }
Exemple #16
0
        public void Delete_ShouldWork()
        {
            string modelTitle   = "TestCreate";
            string modelContent = "TestCreateContent";

            RouteViewModel model = new RouteViewModel
            {
                Title   = modelTitle,
                Content = modelContent,
            };

            User user = new User
            {
                UserName = "******"
            };

            var testOne = this.service.CreateAsync(modelTitle, user).GetAwaiter().GetResult();
            var testTwo = this.service.CreateAsync(modelTitle, user).GetAwaiter().GetResult();

            var result = service.GetAllRoutes();

            Assert.Equal(2, result.Count());

            this.service.DeleteAsync(testOne);

            result = service.GetAllRoutes();
            Assert.Equal(1, result.Count());

            Assert.Equal(testTwo, result.First().Id);

            this.service.DeleteAsync(testTwo);
            result = service.GetAllRoutes();

            result.ShouldBeEmpty();
        }
Exemple #17
0
        public void Test_With_Sample_Json()
        {
            var client = new HttpClient(_server);

            IRouteService routeService =
                (IRouteService) new DependencyResolverBuilder().DependencyResolverWebAPI.GetService(typeof(IRouteService));

            var model = new RouteViewModel
            {
                AddressSearch = new List <AddressSearch>()
                {
                    new AddressSearch("Avenida Paulista", 1000, "São Paulo", "SP"),
                    new AddressSearch("Avenida Paulista", 2000, "São Paulo", "SP")
                },
                RouteType = RouteType.DefaultRouteFaster
            };

            var json = JsonConvert.SerializeObject(model);

            var request = CreateRequest("api/Route", "application/json", HttpMethod.Get, model, new JsonMediaTypeFormatter());


            using (HttpResponseMessage response = client.SendAsync(request).Result)
            {
                Assert.NotNull(response.Content);

                Assert.AreEqual("application/json", response.Content.Headers.ContentType.MediaType);

                var result = JsonConvert.DeserializeObject <Route>(response.Content.ReadAsStringAsync().Result);

                Assert.IsTrue(result.TotalDistance > 0);
            }

            request.Dispose();
        }
Exemple #18
0
        public OkResult Update([FromBody] RouteViewModel city)
        {
            RouteEntity entity = mapper.Map <RouteEntity>(city);

            this.routeService.UpdateRoute(entity);
            return(Ok());
        }
Exemple #19
0
        public ActionResult CreateRoute(RouteViewModel model, List <TransitionalViewModel> modelItem)
        {
            try {
                var train = new TrainDTO
                {
                    Number           = model.Number,
                    DepartureStation = model.DepartureStation,
                    ArrivalStation   = model.ArrivalStation,
                    Departure        = model.Departure,
                    Seats            = model.Seats.Select(s => new SeatDTO {
                        Type     = s.Type,
                        Quantity = s.Quantity,
                        Price    = s.Price
                    }).Where(q => q.Quantity > 0).ToList()
                };
                var stopovers = modelItem.Select(m => new StopoverDTO {
                    StopStation = m.StopStation,
                    Departure   = m.Departure,
                    Arrival     = m.Arrival
                }).ToList();
                rs.AddRoute(train, stopovers, model.SelectedRoute);
                Unit.Save();
                Unit.Dispose();

                return(RedirectToAction("AvailableTrains"));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
Exemple #20
0
        public async Task <IActionResult> Create(RouteViewModel routeViewModel, IFormFile picture)
        {
            if (ModelState.IsValid)
            {
                if (picture != null)
                {
                    var fileName = Path.Combine(_env.WebRootPath, "uploads", Path.GetFileName(picture.FileName));
                    picture.CopyTo(new FileStream(fileName, FileMode.Create));
                }
                var route = new Route
                {
                    Price       = routeViewModel.Price,
                    Description = routeViewModel.Description,
                    CityFrom    = await _context.Cities.FindAsync(routeViewModel.CityFromId),
                    CityTo      = await _context.Cities.FindAsync(routeViewModel.CityToId),
                    Img         = picture.FileName
                };
                _context.Add(route);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Cities"] = (await _context.Cities.ToListAsync()).ConvertAll(c => new SelectListItem {
                Text = c.Title, Value = c.Id.ToString()
            });
            return(View(routeViewModel));
        }
Exemple #21
0
        //
        // GET: /FMM/Route/Detail
        public async Task <ActionResult> Detail(string key)
        {
            using (RouteServiceClient client = new RouteServiceClient())
            {
                MethodReturnResult <Route> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    RouteViewModel viewModel = new RouteViewModel()
                    {
                        Name        = result.Data.Key,
                        Status      = result.Data.Status,
                        CreateTime  = result.Data.CreateTime,
                        Creator     = result.Data.Creator,
                        Description = result.Data.Description,
                        Editor      = result.Data.Editor,
                        EditTime    = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
Exemple #22
0
        public SingleModelResponse <Route> UpdateRoute(RouteViewModel mapRoute)
        {
            string            MapUrl         = MapUri + "Update/EditRoute";
            List <Checkpoint> newCheckPoints = new List <Checkpoint>();

            foreach (CheckpointViewModel check in mapRoute.Checkpoints)
            {
                Checkpoint checkPoint = new Checkpoint();
                checkPoint.Latitude  = check.Latitude;
                checkPoint.Longitude = check.Longitude;
                newCheckPoints.Add(checkPoint);
            }

            var newRoute = new Route
            {
                RouteId    = mapRoute.RouteId,
                UserID     = mapRoute.UserID,
                Title      = mapRoute.Title,
                Distance   = mapRoute.TotalDistance,
                Location   = mapRoute.Location,
                Checkpoint = newCheckPoints
            };
            var createdRoute = PutContent(MapUrl, newRoute);

            return(createdRoute);
        }
Exemple #23
0
        public async Task PostRoutesToFirestore([FromBody] RouteViewModel routeData)
        {
            if (routeData != null)
            {
                CollectionReference collectionReference = db.Collection("RouteList");
                string routeDataFromFrontEnd            = routeData.RouteDescription;
                string zone = "N/A";
                client = new FireSharp.FirebaseClient(config);
                StringReader reader = new StringReader(routeDataFromFrontEnd);
                while ((routeDataFromFrontEnd = reader.ReadLine()) != null)
                {
                    string[] cxLine = routeDataFromFrontEnd.Split("\t");
                    zone = cxLine[2] == null || cxLine[2] == "" ? zone : cxLine[2].ToString();
                    RouteModel routeModel = new RouteModel();

                    routeModel.Dsp    = cxLine[0];
                    routeModel.Zone   = zone;
                    routeModel.Status = "waiting".ToUpper();
                    routeModel.Cx     = cxLine[3];
                    routeModel.Name   = NameParser(cxLine[4]);
                    routeModel.Wave   = Int32.Parse(routeData.Wave);
                    try
                    {
                        await collectionReference.AddAsync(routeModel);
                    }
                    catch (Exception e)
                    {
                        string s = e.ToString();
                    }
                }
                ;
            }
        }
Exemple #24
0
        /// <summary>
        /// 配置路由
        /// </summary>
        /// <param name="model"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public ActionResult ConfigRoute(RouteViewModel model, string property, int value)
        {
            JsonResult result = new JsonResult();
            var        tcpA   = TcpClientServicePool.GetService(model.AIP, model.APort);
            var        tcpB   = TcpClientServicePool.GetService(model.BIP, model.BPort);

            if (tcpA == null)
            {
                result.Data = new { Code = "Exception", Data = "获取A端TCP连接失败" };
            }
            else if (tcpB == null)
            {
                result.Data = new { Code = "Exception", Data = "获取B端TCP连接失败" };
            }
            if (tcpA != null && tcpB != null)
            {
                try
                {
                    List <string> listException = new List <string>();
                    //设置方法名
                    string         methodName = "Set" + property.Replace("_", "");
                    OLPCommService serviceA   = new OLPCommService(tcpA, model.ASlot);
                    bool           ret        = (bool)ReflectionHelper.InvokeMethod(serviceA, methodName, new object[] { value });
                    if (!ret)
                    {
                        listException.Add("A端线路");
                    }
                    OLPCommService serviceB = new OLPCommService(tcpB, model.BSlot);
                    ret = (bool)ReflectionHelper.InvokeMethod(serviceB, methodName, new object[] { value });
                    if (!ret)
                    {
                        listException.Add("B端线路");
                    }
                    if (listException.Count == 0)
                    {
                        result.Data = new { Code = "", Data = "配置成功" };
                    }
                    else
                    {
                        string data = "配置失败:";
                        foreach (var e in listException)
                        {
                            data += e + " ";
                        }
                        result.Data = new { Code = "Exception", Data = data };
                    }
                }
                catch (Exception ex)
                {
                    result.Data = new { Code = "Exception", Data = ex.Message };
                }
                finally
                {
                    TcpClientServicePool.FreeService(tcpA);
                    TcpClientServicePool.FreeService(tcpB);
                }
            }
            return(result);
        }
        private RouteViewModel BuildRouteViewModelFromDomain(DodgingBranches.Models.Route route)
        {
            var returnRoute = new RouteViewModel();

            returnRoute.Name       = route.Name;
            returnRoute.Id         = route.RouteId;
            returnRoute.StartPoint = new RouteMapPoint {
                Latitude = route.StartPoint.Latitude, Longitude = route.StartPoint.Longitude
            };
            returnRoute.EndPoint = new RouteMapPoint {
                Latitude = route.EndPoint.Latitude, Longitude = route.EndPoint.Longitude
            };
            returnRoute.EnteredBy = route.UserId;

            if (route.Comments != null)
            {
                returnRoute.Comments = route.Comments.Select(x => new Models.Comment
                {
                    Id              = x.CommentId,
                    CommentText     = x.CommentText,
                    DateEntered     = x.DateEntered,
                    ParentCommentId = x.ParentCommentId,
                    RouteId         = x.RouteId,
                    UserId          = x.UserId
                }).ToList();
            }

            returnRoute.DateEntered   = route.DateEntered;
            returnRoute.Description   = route.Description;
            returnRoute.StartLocation = new Models.AddressViewModel
            {
                AddressLine1 = route.StartLocation.Address1,
                City         = route.StartLocation.City,
                AddressId    = route.StartLocation.AddressId,
                State        = route.StartLocation.State,
                ZipCode      = route.StartLocation.ZipCode
            };

            returnRoute.EndLocation = new Models.AddressViewModel
            {
                AddressLine1 = route.EndLocation.Address1,
                City         = route.EndLocation.City,
                AddressId    = route.EndLocation.AddressId,
                State        = route.EndLocation.State,
                ZipCode      = route.EndLocation.ZipCode
            };

            if (route.Tags != null)
            {
                returnRoute.Tags = route.Tags.Select(x => new Models.TagViewModel
                {
                    Id      = x.TagId,
                    TagName = x.TagText
                }).ToList();
            }


            return(returnRoute);
        }
        public EditRouteWindow(RouteViewModel editroute)
        {
            InitializeComponent();
            tbKm.Text = editroute.Kilometres.ToString();
            EditRouteWindowVM viewmodel = new EditRouteWindowVM(this, editroute);

            this.DataContext = viewmodel;
        }
        public ActionResult Route()
        {
            string userID = User.Identity.GetUserId();
            var    model  = new RouteViewModel();

            model.GetData(userID, db);
            return(View(model));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            RouteViewModel routeViewModel = db.RouteView.Find(id);

            db.RouteView.Remove(routeViewModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult AppointTrainToRoute(RouteViewModel routeViewModel)
        {
            var mapper   = new MapperConfiguration(cfg => cfg.CreateMap <RouteViewModel, RouteDTO>()).CreateMapper();
            var routeDto = mapper.Map <RouteViewModel, RouteDTO>(routeViewModel);

            _routeService.EditRoute(routeDto);
            return(RedirectToAction("ShowRoutes", "Admin"));
        }
 public EditRouteWindowVM(Window window, RouteViewModel editroute) : base("NewPasTransfDbConnection")
 {
     this.window = window;
     Cities      = GetAllCitiesForRoute();
     Routes      = this.Allroutes;
     route       = editroute;
     InitializeCommands();
 }