示例#1
0
        public async Task <IActionResult> EditBus(EBus busdetal)
        {
            if (ModelState.IsValid)
            {
                var busDetails = new BusDetails
                {
                    Id           = busdetal.Id,
                    BusName      = busdetal.BusName,
                    DriverName   = busdetal.DriverName,
                    DriverPhone  = busdetal.DriverPhone,
                    DeparterTime = busdetal.DeparterTime,
                };
                _db.BusDetails.Update(busDetails);
                var tergetRoute = _db.Route.Where(c => c.BusName == busdetal.BusNameB);
                foreach (Route item in tergetRoute)
                {
                    item.BusName = busDetails.BusName;
                    _db.Route.Update(item);
                }
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(ShowBusList)));
            }
            return(View(busdetal));
        }
示例#2
0
        //public async Task<IActionResult>Index(string search)
        //{
        //    ViewData["GetDetails"] = search;
        //    var bus = from x in _db.Buses select x;
        //    if(!String.IsNullOrEmpty(search))
        //    {
        //        bus = bus.Where(x => x.BusName.Contains(search));
        //    }
        //    return View(await bus.AsNoTracking().ToListAsync());

        //}

        public async Task <IActionResult> Details(int id)
        {
            var bus = new BusDetails();

            using (var client = new HttpClient())
            {
                //using(var response=await client.GetAsync("https://localhost:44329/api/character/GetById"+id))
                using (var response = await client.GetAsync($"{apiurl}/{id}"))
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        bus = JsonConvert.DeserializeObject <BusDetails>(apiResponse);
                    }
                    else
                    {
                        //var noResponse = response.StatusCode.ToString();
                        //return View(noResponse);
                        ViewBag.StatusCode = response.StatusCode;
                    }
                }
            }
            return(View(bus));
        }
示例#3
0
        public ActionResult DeleteConfirmed(int id)
        {
            BusDetails busDetails = db.details.Find(id);

            db.details.Remove(busDetails);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
 public ActionResult Edit([Bind(Include = "ID,busNumber,busTowards,busVia,bStopNumber,busAddress,busStopLocation,latitude,longitude,heading")] BusDetails busDetails)
 {
     if (ModelState.IsValid)
     {
         db.Entry(busDetails).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(busDetails));
 }
示例#5
0
        public async Task <IActionResult> DeleteBus(int?id, BusDetails busDetails)
        {
            var bus = _db.BusDetails.Find(id);

            _db.BusDetails.Remove(bus);
            _db.Route.RemoveRange(_db.Route.Where(c => c.BusName == bus.BusName));
            await _db.SaveChangesAsync();

            return(RedirectToAction("ShowBusList"));
        }
示例#6
0
        public async Task <IActionResult> AddBus(BusDetails busdetails)
        {
            if (ModelState.IsValid)
            {
                _db.BusDetails.Add(busdetails);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(ShowBusList)));
            }
            return(View(busdetails));
        }
        public BusDetails EditBus(int id, BusDetails busDetails)
        {
            var res = _db.Buses.FirstOrDefault(e => e.BusId == id);

            res.BusName  = busDetails.BusName;
            res.Category = busDetails.Category;
            res.Capacity = busDetails.Capacity;
            res.Trips    = busDetails.Trips;

            _db.SaveChanges();
            return(res);
        }
示例#8
0
        // GET: BusDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BusDetails busDetails = db.details.Find(id);

            if (busDetails == null)
            {
                return(HttpNotFound());
            }
            return(View(busDetails));
        }
示例#9
0
        public async Task <IActionResult> DeleteBus(int id)
        {
            var busdata = new BusDetails();

            using (HttpClient client = new HttpClient())
            {
                //using (var response = await client.GetAsync("https://localhost:44330/api/Character"))
                using (var response = await client.DeleteAsync($"{apiurl}/{id}"))
                {
                    var apiResponse = await response.Content.ReadAsStringAsync();

                    busdata = JsonConvert.DeserializeObject <BusDetails>(apiResponse);
                }
            }
            return(RedirectToAction("Index"));
        }
示例#10
0
        public async Task <IActionResult> Create(BusDetails busDetails)
        {
            var resbus = new BusDetails();

            using (var client = new HttpClient())
            {
                var content = new StringContent(JsonConvert.SerializeObject(busDetails), Encoding.UTF8, "application/json");
                using (var response = await client.PostAsync(apiurl, content))
                {
                    var apiResponse = await response.Content.ReadAsStringAsync();

                    resbus = JsonConvert.DeserializeObject <BusDetails>(apiResponse);
                }
            }
            return(RedirectToAction("Index"));
            //return View(rescharacter);
        }
示例#11
0
        public async Task <IActionResult> Edit(int id, BusDetails busDetails)
        {
            var busdata = new BusDetails();

            using (var client = new HttpClient())
            {
                var content = new StringContent(JsonConvert.SerializeObject(busDetails), Encoding.UTF8,
                                                "application/json");
                using (var response = await client.PutAsync($"{apiurl}/{id}", content))
                {
                    var apiResponse = await response.Content.ReadAsStringAsync();

                    busdata = JsonConvert.DeserializeObject <BusDetails>(apiResponse);
                }
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteBusDetails(BusDetailsViewModel mod)
        {
            BusDetails deleteDetails = db.BusDetails.Find(mod.Id);

            db.BusDetails.Remove(deleteDetails);

            //AvailabilityDetails deleteavailDetails = db.AvailabilityDetails.;
            //db.AvailabilityDetails.Remove(deleteavailDetails);
            //db.SaveChanges();

            foreach (var availDetails in db.AvailabilityDetails.Where(m => m.BusDetailsId == mod.Id).ToList())
            {
                db.AvailabilityDetails.Remove(availDetails);
            }
            db.SaveChanges();
            mod.Id = 0;
            return(RedirectToAction("Index"));
        }
 private async Task <DialogTurnResult> BusTypeStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
 {
     busDetail = (BusDetails)stepContext.Options;
     if (busDetail.RouteNum == null)
     {
         return(await stepContext.PromptAsync(nameof(ChoicePrompt),
                                              new PromptOptions {
             Prompt = MessageFactory.Text("어떤 버스를 이용하시나요?"),
             RetryPrompt = MessageFactory.Text("아래 버스 중에서 골라주십시오"),
             Choices = ChoiceFactory.ToChoices(new List <string> {
                 "셔틀버스", "성북02", "종로03"
             })
         }, cancellationToken));
     }
     else
     {
         return(await stepContext.NextAsync(busDetail.RouteNum, cancellationToken));
     }
 }
        public static void CreateBusDetailsXMLData()
        {
            BusDetails[] busDetails = new BusDetails[10];
            busDetails[0] = new BusDetails(0001, 50, 100);
            busDetails[1] = new BusDetails(0002, 51, 110);
            busDetails[2] = new BusDetails(0003, 52, 120);
            busDetails[3] = new BusDetails(0011, 53, 130);
            busDetails[4] = new BusDetails(0012, 54, 140);
            busDetails[5] = new BusDetails(0013, 55, 150);
            busDetails[6] = new BusDetails(0021, 56, 160);
            busDetails[7] = new BusDetails(0022, 57, 170);
            busDetails[8] = new BusDetails(0023, 58, 180);


            using (XmlWriter writer = XmlWriter.Create(Constant.XML_FILE_NAME_BUSDETAILS))
            {
                writer.WriteStartDocument();
                writer.WriteWhitespace("\n");
                writer.WriteStartElement(Constant.XML_ROOT_ELEMENT_BUSDETAILS);
                writer.WriteWhitespace("\n");

                foreach (BusDetails busDetail in busDetails)
                {
                    writer.WriteStartElement(Constant.XML_ELEMENT_NODE_BUSDETAILS);

                    writer.WriteAttributeString("Bus_Route_Number", busDetail.o_RouteNumber.ToString());
                    writer.WriteAttributeString("Number_of_Available_Seats", busDetail.o_AvailableSeats.ToString());
                    writer.WriteAttributeString("Bus_Fare", busDetail.o_BusFare.ToString());

                    writer.WriteEndElement();
                    writer.WriteWhitespace("\n");
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
            }
        }
        public static void CreateBusDetailsXMLData()
        {
            BusDetails[] busDetails = new BusDetails[10];
            busDetails[0] = new BusDetails(0001, 50, 100);
            busDetails[1] = new BusDetails(0002, 51, 110);
            busDetails[2] = new BusDetails(0003, 52, 120);
            busDetails[3] = new BusDetails(0011, 53, 130);
            busDetails[4] = new BusDetails(0012, 54, 140);
            busDetails[5] = new BusDetails(0013, 55, 150);
            busDetails[6] = new BusDetails(0021, 56, 160);
            busDetails[7] = new BusDetails(0022, 57, 170);
            busDetails[8] = new BusDetails(0023, 58, 180);

            using (XmlWriter writer = XmlWriter.Create(Constant.XML_FILE_NAME_BUSDETAILS))
            {
                writer.WriteStartDocument();
                writer.WriteWhitespace("\n");
                writer.WriteStartElement(Constant.XML_ROOT_ELEMENT_BUSDETAILS);
                writer.WriteWhitespace("\n");

                foreach (BusDetails busDetail in busDetails)
                {
                    writer.WriteStartElement(Constant.XML_ELEMENT_NODE_BUSDETAILS);

                    writer.WriteAttributeString("Bus_Route_Number", busDetail.o_RouteNumber.ToString());
                    writer.WriteAttributeString("Number_of_Available_Seats", busDetail.o_AvailableSeats.ToString());
                    writer.WriteAttributeString("Bus_Fare", busDetail.o_BusFare.ToString());

                    writer.WriteEndElement();
                    writer.WriteWhitespace("\n");
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
            }
        }
        public ActionResult EditBusDetails(BusDetailsViewModel mod)
        {
            BusDetails editDetails = db.BusDetails.Find(mod.Id);

            mod.CompanyId         = editDetails.BusCompanyNameId;
            mod.BusTypeId         = editDetails.BusTypeId;
            mod.NumOfChairSeats   = editDetails.NumOfChairSeats;
            mod.NumOfSleeperSeats = editDetails.NumOfSleeperSeats;
            mod.BusNumber         = editDetails.BusNumber;
            mod.Id = editDetails.Id;

            AvailabilityDetails editAvailDetails = db.AvailabilityDetails.FirstOrDefault(m => m.BusDetailsId == mod.Id);

            mod.OriginLocation      = editAvailDetails.OriginLocation;
            mod.DestinationLocation = editAvailDetails.DestinationLocation;

            mod.BusCompanyNames      = db.BusCompanyNames.ToList();
            mod.OriginLocations      = db.Locations.ToList();
            mod.DestinationLocations = db.Locations.ToList();
            mod.BusTypes             = db.BusTypes.ToList();
            mod.AvailabilityDetails  = db.AvailabilityDetails.Include("BusDetails").ToList();

            return(View("Index", mod));
        }
        public IActionResult UpdateBus(int id, [FromBody] BusDetails busDetails)
        {
            var resUpdate = _travelRepository.EditBus(id, busDetails);

            return(Ok(resUpdate));
        }
        public ActionResult addBusDetails(BusDetailsViewModel mod)
        {
            if (mod.DestinationLocation == mod.OriginLocation)
            {
                ModelState.AddModelError("DestinationLocation", "Destination location cannot be same as the origin location");
            }
            try
            {
                if (ModelState.IsValid)
                {
                    if (mod.Id == 0)
                    {
                        BusDetails addBusDetails = new BusDetails();
                        addBusDetails.BusCompanyNameId  = mod.CompanyId;
                        addBusDetails.BusTypeId         = mod.BusTypeId;
                        addBusDetails.NumOfChairSeats   = mod.NumOfChairSeats;
                        addBusDetails.NumOfSleeperSeats = mod.NumOfSleeperSeats;
                        addBusDetails.BusNumber         = mod.BusNumber;
                        db.BusDetails.Add(addBusDetails);
                        db.SaveChanges();

                        AvailabilityDetails availDetails = new AvailabilityDetails();
                        availDetails.BusDetailsId        = addBusDetails.Id;
                        availDetails.OriginLocation      = mod.OriginLocation;
                        availDetails.DestinationLocation = mod.DestinationLocation;
                        db.AvailabilityDetails.Add(availDetails);

                        AvailabilityDetails addReturnJourneyDetails = new AvailabilityDetails();
                        addReturnJourneyDetails.BusDetailsId        = addBusDetails.Id;
                        addReturnJourneyDetails.OriginLocation      = mod.DestinationLocation;
                        addReturnJourneyDetails.DestinationLocation = mod.OriginLocation;
                        addReturnJourneyDetails.IsReturn            = true;
                        db.AvailabilityDetails.Add(addReturnJourneyDetails);
                        db.SaveChanges();
                    }

                    else
                    {
                        BusDetails editedDetails = db.BusDetails.Find(mod.Id);
                        editedDetails.BusCompanyNameId  = mod.CompanyId;
                        editedDetails.BusTypeId         = mod.BusTypeId;
                        editedDetails.NumOfChairSeats   = mod.NumOfChairSeats;
                        editedDetails.NumOfSleeperSeats = mod.NumOfSleeperSeats;
                        editedDetails.BusNumber         = mod.BusNumber;


                        AvailabilityDetails editedAvailDetails = db.AvailabilityDetails.Where(m => m.BusDetailsId == editedDetails.Id).FirstOrDefault();
                        // editedAvailDetails.BusDetailsId = editedDetails.Id;
                        editedAvailDetails.OriginLocation      = mod.OriginLocation;
                        editedAvailDetails.DestinationLocation = mod.DestinationLocation;

                        AvailabilityDetails editReturnJourneyDetails = db.AvailabilityDetails.Where(m => m.BusDetailsId == editedDetails.Id && m.IsReturn == true).FirstOrDefault();
                        editReturnJourneyDetails.OriginLocation      = mod.DestinationLocation;
                        editReturnJourneyDetails.DestinationLocation = mod.OriginLocation;
                        db.SaveChanges();
                    }

                    return(RedirectToAction("Index"));
                }
            }

            catch (Exception ex)
            {
                if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key row"))
                {
                    ModelState.AddModelError("BusNumber", "This bus number is already in use");
                }
            }

            mod.BusCompanyNames      = db.BusCompanyNames.ToList();
            mod.OriginLocations      = db.Locations.ToList();
            mod.DestinationLocations = db.Locations.ToList();
            mod.BusTypes             = db.BusTypes.ToList();
            mod.AvailabilityDetails  = db.AvailabilityDetails.Include("BusDetails").ToList();
            return(View("Index", mod));
        }
示例#19
0
        public async Task AttachBusCardAsync(ITurnContext turnContext, BusDetails busDetails, string arrmsg1, string arrmsg2, CancellationToken cancellationToken)
        {
            if (arrmsg1 == "" || arrmsg1 == "운행종료")
            {
                await turnContext.SendActivityAsync(MessageFactory.Text($"현재 운행중인 {busDetails.RouteNum}번 버스가 없습니다."));

                return;
            }
            arrmsg2 = arrmsg2 == "운행종료" ? "" : arrmsg2;

            var card = new AdaptiveCard();

            card.Body.Add(new AdaptiveTextBlock
            {
                Text   = busDetails.RouteNum,
                Weight = AdaptiveTextWeight.Bolder,
                HorizontalAlignment = AdaptiveHorizontalAlignment.Center,
                Size = AdaptiveTextSize.Large
            });
            card.Body.Add(new AdaptiveColumnSet
            {
                Columns = new List <AdaptiveColumn>
                {
                    new AdaptiveColumn
                    {
                        Items = new List <AdaptiveElement>
                        {
                            new AdaptiveTextBlock
                            {
                                Text   = "|",
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            },
                            new AdaptiveTextBlock
                            {
                                Text   = "|",
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            },
                            new AdaptiveTextBlock
                            {
                                Text   = "|",
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            },
                            new AdaptiveTextBlock
                            {
                                Text   = "|",
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            },
                            new AdaptiveTextBlock
                            {
                                Text   = "|",
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            },
                        }
                    },
                    new AdaptiveColumn
                    {
                        Items = new List <AdaptiveElement>
                        {
                            new AdaptiveTextBlock
                            {
                                Text   = busDetails.StationName,
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            },
                            new AdaptiveTextBlock
                            {
                                Text   = arrmsg1,
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            },
                            new AdaptiveTextBlock
                            {
                                Text   = "-",
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            },
                            new AdaptiveTextBlock
                            {
                                Text   = arrmsg2,
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            },
                            new AdaptiveTextBlock
                            {
                                Text   = "-",
                                Weight = AdaptiveTextWeight.Bolder,
                                Size   = AdaptiveTextSize.ExtraLarge,
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Center
                            }
                        }
                    },
                    new AdaptiveColumn
                    {
                        Items = new List <AdaptiveElement>
                        {
                            new AdaptiveImage
                            {
                                HorizontalAlignment = AdaptiveHorizontalAlignment.Right,
                                Url = new Uri("https://postfiles.pstatic.net/20160412_82/hanlee42_1460451251100Rlzv8_PNG/bus-161893_1280.png?type=w2")
                            }
                        }
                    }
                }
            });

            var reply = MessageFactory.Attachment(new Attachment
            {
                ContentType = "application/vnd.microsoft.card.adaptive",
                Content     = JsonConvert.DeserializeObject(card.ToJson())
            });

            await turnContext.SendActivityAsync(reply, cancellationToken);
        }
示例#20
0
        public async Task <MainDetail> ExecuteLuisQuery(ILogger logger, ITurnContext turnContext, CancellationToken cancellationToken)
        {
            MainDetail detail = new MainDetail();

            try {
                LuisRecognizer luisRecognizer = new LuisRecognizer(luisApplication);
                recognizerResult = await luisRecognizer.RecognizeAsync(turnContext, cancellationToken);

                //높은 점수의 의도 저장
                var(intent, score) = recognizerResult.GetTopScoringIntent();
                //대화의도에 따른 엔티티 저장

                switch (intent)
                {
                case "버스":
                    BusDetails busDetails = new BusDetails();
                    busDetails.intent = intent;
                    busDetails        = getLuisEntites(busDetails);
                    detail            = busDetails;
                    break;

                case "미세먼지":
                    DustDetails dustDetails = new DustDetails();
                    dustDetails.intent = intent;
                    dustDetails        = getDustLuisEntites(dustDetails);
                    detail             = dustDetails;
                    break;

                case "장학제도":
                    detail.intent = intent;
                    break;

                case "전화번호":
                    PhoneDetails phoneDetails = new PhoneDetails();
                    phoneDetails.intent = intent;
                    phoneDetails        = getPhoneEntites(phoneDetails);
                    detail = phoneDetails;
                    break;

                case "교수님":
                    ProfessorsDetail pfDetail = new ProfessorsDetail();
                    pfDetail.intent = intent;
                    pfDetail        = getProfessorEntites(pfDetail);
                    detail          = pfDetail;
                    break;

                case "트랙정보":
                    TrackInfoCardDetail trackInfoCardDetail = new TrackInfoCardDetail();
                    trackInfoCardDetail.intent = intent;
                    detail = trackInfoCardDetail;
                    break;

                case "공지사항":
                    NoticeDetail noticeDetail = new NoticeDetail();
                    noticeDetail.intent = intent;
                    detail = noticeDetail;
                    break;

                case "맛집":
                    MatjeepchoochunDetail matjeepchoochunDetail = new MatjeepchoochunDetail();
                    matjeepchoochunDetail.intent = intent;
                    matjeepchoochunDetail        = getMatjeepchoochunEntites(matjeepchoochunDetail);
                    detail = matjeepchoochunDetail;
                    break;

                case "학식메뉴":
                    detail.intent = intent;
                    break;

                case "로그인":
                    MainDetail loginDetail = new MainDetail();
                    loginDetail.intent = intent;
                    detail             = loginDetail;
                    break;

                case "시간표":
                    MainDetail timeDetail = new MainDetail();
                    timeDetail.intent = intent;
                    detail            = timeDetail;
                    break;

                case "열람실":
                    MainDetail seatDetail = new MainDetail();
                    seatDetail.intent = intent;
                    detail            = seatDetail;
                    break;
                }
            }
            catch (Exception e)
            {
                await turnContext.SendActivityAsync(MessageFactory.Text("예기치 못한 오류가 발생하였습니다. 다시 시도해주십시오\n" + e.Message), cancellationToken);
            }

            return(detail);
        }
示例#21
0
 private BusDetails getLuisEntites(BusDetails busDetails)
 {
     busDetails.RouteNum    = recognizerResult.Entities["노선번호"]?.FirstOrDefault()?.FirstOrDefault()?.ToString().Replace(" ", "");
     busDetails.StationName = recognizerResult.Entities["버스정류장"]?.FirstOrDefault()?.FirstOrDefault()?.ToString().Replace(" ", "");
     return(busDetails);
 }
        public IActionResult AddNewBus([FromBody] BusDetails busDetails)
        {
            var addBus = _travelRepository.AddBus(busDetails);

            return(Ok(addBus));
        }
 public BusDetails AddBus(BusDetails busDetails)
 {
     _db.Buses.Add(busDetails);
     _db.SaveChanges();
     return(busDetails);
 }