Example #1
0
        public async Task <ActionResult> AddNewRole(SaveRoleResource saveRoleResource)
        {
            var role = mapper.Map <Role>(saveRoleResource);

            await roleRepository.AddAsync(role);

            await unitOfWork.SaveAsync();

            var categoryResource = mapper.Map <KeyValuePairResource>(role);

            return(Ok(categoryResource));
        }
Example #2
0
        public async Task <ActionResult> UpdateExistintRole(int roleId, SaveRoleResource saveRoleResource)
        {
            var role = await roleRepository.FindUniqueAsync(c => c.Id == roleId);

            if (role is null)
            {
                return(NotFound("Role not found"));
            }

            mapper.Map <SaveRoleResource, Core.Entities.Role>(saveRoleResource, role);

            await unitOfWork.SaveAsync();

            var roleResource = mapper.Map <KeyValuePairResource>(role);

            return(Ok(roleResource));
        }