예제 #1
0
        public async Task <ActionResult <BonusDto> > Post([FromBody] BonusDto model)
        {
            try
            {
                var createdBonus = await _bonusRepository.AddBonusAsync(model);

                var location = _linkGenerator.GetPathByAction("GetBonusByID", "Bonus", new { id = model.JobDescriptionId });
                if (string.IsNullOrWhiteSpace(location))
                {
                    return(BadRequest($"The URI was not found"));
                }
                return(Created(location, createdBonus));
            }
            catch (Exception ex)
            {
                return(BadRequest(new Response {
                    Success = false, Message = ex.Message
                }));
            }
        }