예제 #1
0
        public async Task <IActionResult> GetAll()
        {
            var result = await vehicleService.GetAll();

            if (result.ResultCode == ResultCode.Success)
            {
                Response.Headers.Add("x-total-count", result.Data.Count().ToString());
                var formattedResult = dataStructureConverter
                                      .ConvertAndMap <IEnumerable <VehicleModel>, IEnumerable <Vehicle> >("vehicles", result.Data);
                return(Ok(formattedResult));
            }

            return(errorCodeConverter.Convert(result.ResultCode));
        }
        public async Task <IActionResult> Post([FromBody] LoginModel loginModel)
        {
            try
            {
                var result = await authenticateUser.Execute(loginModel);

                if (result.ResultCode == ResultCode.Success)
                {
                    return(Ok(result.Data));
                }
                return(errorCodeConverter.Convert(result.ResultCode));
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.Message));
            }
        }
예제 #3
0
        public async Task <IActionResult> Post([FromBody] LogEntryModel logEntryModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var log = dataStructureConverter.Map <LogEntry, LogEntryModel>(logEntryModel);

            var result = await logService.Log(log);

            if (result.ResultCode == ResultCode.Success)
            {
                return(Created(string.Empty, log.Message));
            }

            return(errorCodeConverter.Convert(result.ResultCode));
        }