public async Task <IActionResult> PutRole(Guid id, Role role)
        {
            if (id != role.Id)
            {
                return(BadRequest());
            }

            _context.Entry(role).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PutProjectKeyIndicatorYear(Guid id, ProjectKeyIndicatorYear projectKeyIndicatorYear)
        {
            if (id != projectKeyIndicatorYear.Id)
            {
                return(BadRequest());
            }

            _context.Entry(projectKeyIndicatorYear).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectKeyIndicatorYearExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutOperationalCompany(Guid id, OperationalCompany operationalCompany)
        {
            if (id != operationalCompany.Id)
            {
                return(BadRequest());
            }

            _context.Entry(operationalCompany).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OperationalCompanyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #4
0
        public async Task <UserDto> Post(UserDto user)
        {
            var userData = _mapper.Map <UserDto, Classes.Entity.User>(user);

            // to be removed
            userData.Password = "******";
            _context.Users.Add(userData);
            await _context.SaveChangesAsync();

            return(user);
        }
Exemple #5
0
        private static void SeedPermissions(KiteContext context)
        {
            if (context.Permissions.Any())
            {
                return;
            }

            var permisssions = new List <Permission>()
            {
                new Permission()
                {
                    PermissionType = "Create"
                },
                new Permission()
                {
                    PermissionType = "Read"
                },
                new Permission()
                {
                    PermissionType = "Update"
                },
                new Permission()
                {
                    PermissionType = "Delete"
                }
            };

            context.Permissions.AddRange(permisssions);
            context.SaveChangesAsync();
        }
Exemple #6
0
        private static void SeedRoles(KiteContext context)
        {
            if (context.Roles.Any())
            {
                return;
            }

            var roles = new List <Role>()
            {
                new Role()
                {
                    RoleType = "Admin"
                },
                new Role()
                {
                    RoleType = "IDC Lead"
                },
                new Role()
                {
                    RoleType = "Opco Lead"
                },
                new Role()
                {
                    RoleType = "Project Lead"
                }
            };

            context.Roles.AddRange(roles);
            context.SaveChangesAsync();
        }
        public async Task <ActionResult <User> > DeleteUser(Guid id)
        {
            var user = await _context.Users.FindAsync(id);

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

            _context.Users.Remove(user);
            await _context.SaveChangesAsync();

            return(user);
        }