public Block ModifyBlock(BlockModifyDto b) { var map = mapper1.Map <Block>(b); Block old = blockingRepository1.Modify(map); return(old); }
public ActionResult <BlockDto> Modify_Block([FromHeader] string key, BlockModifyDto blockModify) { if (!authHelper1.AuthUser(key)) { logger.LogWarning("Autorizacija korisnika neuspesna"); return(Unauthorized()); } if (!followingMockRepository1.FollowingUser(blockModify.BlockerId, blockModify.BlockedId)) { logger.LogWarning("Korisnik ne moze da blokira korisnika kojeg ne prati"); return(StatusCode(StatusCodes.Status400BadRequest, $"You don't follow user with id = {blockModify.BlockedId}, so you can't block him!")); } try { Block old = blockingService1.ModifyBlock(blockModify); logger.LogInformation("Blok je uspesno modifikovan"); return(Ok(mapper.Map <BlockDto>(old))); } catch (Exception e) { logger.LogError(e.Message); return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }