Пример #1
0
        public async Task <IActionResult> OnPostEditRoute()
        {
            string       respone = "waiting";
            MemoryStream stream  = new MemoryStream();

            Request.Body.CopyTo(stream);
            stream.Position = 0;
            using (StreamReader reader = new StreamReader(stream))
            {
                string requestBody = reader.ReadToEnd();
                if (requestBody.Length > 0)
                {
                    var obj = JsonConvert.DeserializeObject <RouteVM>(requestBody);
                    if (obj != null)
                    {
                        FlightTimeDTO flightTime = new FlightTimeDTO(obj.Hour, obj.Minute);

                        RouteDTO Route = new RouteDTO(obj.RouteId, obj.Origin, obj.Destination, flightTime, obj.Status);
                        await _servicesVM.UpdateRoute(Route);

                        respone = "successful";
                    }
                }
            }
            return(new JsonResult(respone));
        }
Пример #2
0
        public async Task <IActionResult> OnPostCreateRoute()
        {
            string       respone = "True";
            MemoryStream stream  = new MemoryStream();

            Request.Body.CopyTo(stream);
            stream.Position = 0;
            using (StreamReader reader = new StreamReader(stream))
            {
                string requestBody = reader.ReadToEnd();
                if (requestBody.Length > 0)
                {
                    var obj = JsonConvert.DeserializeObject <RouteVM>(requestBody);
                    if (obj != null)
                    {
                        FlightTimeDTO flightTime = new FlightTimeDTO(obj.Hour, obj.Minute);
                        RouteDTO      Route      = new RouteDTO();
                        Route.Origin      = obj.Origin;
                        Route.Destination = obj.Destination;
                        Route.FlightTime  = flightTime;
                        Route.Status      = obj.Status;
                        // Route.RouteId = obj.RouteId;
                        await _servicesVM.AddRoute(Route);
                    }
                }
            }
            return(new JsonResult(respone));
        }