public IActionResult Create([FromForm] Flight flight)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, new Response
                    {
                        Status = "Error",
                        Messages = new Message[] {
                            new Message {
                                Lang_id = 1,
                                MessageLang = "Model state isn't valid!"
                            },
                            new Message {
                                Lang_id = 2,
                                MessageLang = "Состояние модели недействительно!"
                            },
                            new Message {
                                Lang_id = 3,
                                MessageLang = "Model vəziyyəti etibarsızdır!"
                            }
                        }
                    }));
                }

                _flightContext.Add(flight);
                return(Ok());
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }
        public IActionResult Post([FromBody] FlightDTO flight)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = _service.Add(flight);

            return(result == true?StatusCode(200) : StatusCode(500));
        }
        public ActionResult Add(FlightModel flight)
        {
            if (ModelState.IsValid)
            {
                var flightDTO = _flightMaper.MapBack(flight);
                _flightService.Add(flightDTO);

                return(RedirectToAction("List"));
            }
            else
            {
                List <CompanyDTO> companyDTOList = _companyService.GetAll();
                var companyList = _companyMaper.Map(companyDTOList);
                ViewBag.CompanyList = companyList;

                List <CityDTO> cityDTOList = _cityService.GetAll();
                var            cityList    = _cityMaper.Map(cityDTOList);
                ViewBag.CityList = cityList;

                return(View());
            }
        }
        public ActionResult Create(flight f)
        {
            //debut code khawla
            IUserService service   = new UserService();
            user         u         = service.GetById(User.Identity.GetUserId());
            string       firstName = u.firstName;
            string       lastName  = u.lastName;
            string       email     = u.Email;

            ViewBag.userFirstName = firstName;
            ViewBag.userLastName  = lastName;
            ViewBag.userMail      = email;
            ViewBag.sexe          = u.sexe.ToLower();
            //fin code khawla
            if (ModelState.IsValid)
            {
                ause.Add(f);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
        public async Task <IActionResult> Post([FromBody] Flight flight)
        {
            await _flightService.Add(flight);

            return(_flightPresenter.ViewModel);
        }