public async Task <IActionResult> UpdateUser(int id, UserForUpdateDto userForUpdateDto)
        {
            var userFromRepo = await _repo.GetUser(id);

            _mapper.Map(userForUpdateDto, userFromRepo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Updating User {id} failed on save");
        }
        public async Task <IActionResult> UpdateFMAdmin(int id, FMAdminForUpdateDto fmAdminForUpdateDto)
        {
            var fmAdminFromRepo = await _repo.GetFMAdmin(id);

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

            _mapper.Map(fmAdminForUpdateDto, fmAdminFromRepo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Updating File Manager Admin {id} failed on save");
        }
Beispiel #3
0
        public async Task <IActionResult> UpdateLabel(int id, LabelForListDto labelForListDto)
        {
            var labelFromRepo = await _repo.GetLabel(id);

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

            _mapper.Map(labelForListDto, labelFromRepo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Updating Label {id} failed on save");
        }
        public async Task <IActionResult> UpdateRole(int id, RoleForUpdateDto roleForUpdateDto)
        {
            var roleFromRepo = await _repo.GetRole(id);

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

            _mapper.Map(roleForUpdateDto, roleFromRepo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Updating Role {id} failed on save");
        }
Beispiel #5
0
        public async Task <IActionResult> UpdateUser(int id, UserForUpdateDto userForUpdateDto)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var userFromRepo = await _repo.GetUser(id);

            _mapper.Map(userForUpdateDto, userFromRepo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Updating User {id} failed on save");
        }
        public async Task <IActionResult> UpdateCompany(int id, CompanyForUpdateDto companyForUpdateDto)
        {
            var companyFromRepo = await _repo.GetCompany(id);

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

            _mapper.Map(companyForUpdateDto, companyFromRepo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Updating Company {id} failed on save");
        }