Exemple #1
0
        public IHttpActionResult Post([FromBody] LicenseModel model)
        {
            try
            {
                if (!ModelState.IsValid || (int)model.Type < 1 || (int)model.Type > 3)
                {
                    return(BadRequest("Cannot create licence."));
                }

                var result = _service.Create(model);
                if (!string.IsNullOrEmpty(result))
                {
                    return(Ok(result));
                }
            }
            catch (Exception ex)
            {
                _logger.Log(NLog.LogLevel.Error, ex);

                return(BadRequestWithError(ApiErrorEnum.GeneralError));
            }

            return(BadRequestWithError(ApiErrorEnum.LicenseCreateFailed, "Cannot create licence."));
        }