示例#1
0
        public async Task <IActionResult> Add([FromBody] LcdaModel lcdaModel)
        {
            long lastId = await _lcdaService.LastId();

            lcdaModel.LcdaCode = _codeGenerationService.NewLcdaCode(lastId);
            bool result = await _lcdaService.Add(lcdaModel);

            if (result)
            {
                // add current user to the lcda
                LcdaModel lModel = await _lcdaService.Get(lcdaModel.LcdaCode);

                return(Ok(new ResponseModel()
                {
                    code = ResponseCode.SUCCESSFULL,
                    data = lModel.Id,
                    description = $"{lcdaModel.LcdaName} has been created successfully"
                }));
            }

            throw new BadRequestException("An error occur while processing your request. Please try again or contact an administrator");
        }