public async Task <IActionResult> Update(int id, [FromBody] SaveDormitoryBlockResource dormitoryBlockResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dormitoryBlock = await dormitoryBlockRepository.GetOne(id);

            if (dormitoryBlock == null)
            {
                return(NotFound());
            }

            dormitoryBlock = mapper.Map(dormitoryBlockResource, dormitoryBlock);

            dormitoryBlockRepository.Update(dormitoryBlock);

            if (await unitOfWork.CompleteAsync() == false)
            {
                throw new Exception(message: $"Updating dormitoryBlock {id} failed on save");
            }

            dormitoryBlock = await dormitoryBlockRepository.GetOne(dormitoryBlock.Id);

            var result = mapper.Map <DormitoryBlock, ViewDormitoryBlockResource>(dormitoryBlock);

            return(Ok(result));
        }
        public async Task <IActionResult> Create([FromBody] SaveDormitoryBlockResource dormitoryBlockResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dormitoryBlock = mapper.Map <SaveDormitoryBlockResource, DormitoryBlock>(dormitoryBlockResource);

            dormitoryBlockRepository.Add(dormitoryBlock);
            if (await unitOfWork.CompleteAsync() == false)
            {
                throw new Exception(message: $"Create new dormitoryBlock fail on save");
            }

            dormitoryBlock = await dormitoryBlockRepository.GetOne(dormitoryBlock.Id);

            var result = mapper.Map <DormitoryBlock, ViewDormitoryBlockResource>(dormitoryBlock);

            return(Ok(result));
        }