Example #1
0
        public IActionResult CreateLink([FromBody] CreateLinkRequestDto body)
        {
            var validity = body.Validate();

            if (validity != null)
            {
                return(BadRequest(validity));
            }

            // Authorize user
            long tokenId = int.Parse(User.Claims.First(x => x.Type == "uid").Value);

            if (body.userId != tokenId)
            {
                return new ObjectResult(new ForbiddenDto())
                       {
                           StatusCode = 403
                       }
            }
            ;

            var link = body.ToDomain();
            var id   = _service.Add(link);

            return(Ok(new CreateLinkSuccessResponseDto(id)));
        }
Example #2
0
 public void AddLink(
     Table masterTable,
     Table slaveTable,
     bool isCascadeDelete = false,
     bool isCascadeUpdate = false)
 {
     _linkService.Add(
         masterTable: masterTable,
         slaveTable: slaveTable,
         isCascadeDelete: isCascadeDelete,
         isCascadeUpdate: isCascadeUpdate);
 }
 public IActionResult Create([FromBody] LinkModel model)
 {
     _service.Add(model);
     return(Ok(model));
 }