/// <summary>
 /// Copies data from another map control view model.
 /// </summary>
 public void CopyFrom(MapControlViewModel other)
 {
     this.userLocation = other.userLocation;
     this.busStops = other.busStops;
     this.mapView = other.mapView;
     this.shapes = other.shapes;
     this.selectedBusStop = other.selectedBusStop;
 }
Example #2
0
 /// <summary>
 /// Copies data from another map control view model.
 /// </summary>
 public void CopyFrom(MapControlViewModel other)
 {
     this.userLocation    = other.userLocation;
     this.busStops        = other.busStops;
     this.mapView         = other.mapView;
     this.shapes          = other.shapes;
     this.selectedBusStop = other.selectedBusStop;
 }
        public IActionResult Insert(LineNameVM lineNameVM)
        {
            if (ModelState.IsValid)
            {
                if (_unitOfWork.LineName.GetFirstOrDefault(ln => ln.Name == lineNameVM.lineName.Name) != null)
                {
                    return(RedirectToAction(nameof(RepeatedName)));
                }
                else
                {
                    lineNameVM.lineName.IsActive = true;
                    _unitOfWork.LineName.Add(lineNameVM.lineName);
                    _unitOfWork.Save();

                    int iter = 1;
                    foreach (var item in lineNameVM.busStopList)
                    {
                        if (_unitOfWork.BusStop.Get(item.BusStopId).Name == "Brak")
                        {
                            break;
                        }
                        BusStopList busStopList = new BusStopList();
                        busStopList.BusStopNumber = iter;
                        busStopList.BusStopId     = item.BusStopId;
                        busStopList.LineNameId    = _unitOfWork.LineName.GetLast().Id;
                        _unitOfWork.BusStopList.Add(busStopList);
                        _unitOfWork.Save();
                        iter++;
                    }

                    if (lineNameVM.IsReversedToo)
                    {
                        LineName lineNameReversed = new LineName()
                        {
                            Name     = lineNameVM.ReversedLineName,
                            IsActive = true
                        };

                        _unitOfWork.LineName.Add(lineNameReversed);
                        _unitOfWork.Save();

                        iter = 1;
                        for (int i = lineNameVM.busStopList.Count - 1; i >= 0; i--)
                        {
                            if (_unitOfWork.BusStop.Get(lineNameVM.busStopList[i].BusStopId).Name == "Brak")
                            {
                                break;
                            }
                            BusStopList busStopList = new BusStopList();
                            busStopList.BusStopNumber = iter;
                            busStopList.BusStopId     = lineNameVM.busStopList[i].BusStopId;
                            busStopList.LineNameId    = _unitOfWork.LineName.GetLast().Id;
                            _unitOfWork.BusStopList.Add(busStopList);
                            _unitOfWork.Save();
                            iter++;
                        }
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(lineNameVM));
            }
        }