public async Task <bool> Create(CreateProject createProject, AppUser user)
        {
            string slug = createProject.ProjectName.ToLower().Replace(" ", "-");

            Project project = new Project
            {
                ProjectName = createProject.ProjectName,
                Slug        = slug,
                Author      = user
            };

            project.UserProjects = new List <UserProject>
            {
                new UserProject
                {
                    AppUser = user,
                    Project = project
                }
            };

            await context.Projects.AddAsync(project);

            int saveResult = await context.SaveChangesAsync();

            System.Diagnostics.Debug.WriteLine(saveResult.ToString());
            return(saveResult == 2);
        }
Beispiel #2
0
        public async Task <bool> Delete(int id)
        {
            Story story = await context.Stories.FindAsync(id);

            context.Stories.Remove(story);
            int saveResult = await context.SaveChangesAsync();

            return(saveResult == 1);
        }
        public async Task <bool> CreateInvitation(ProjectInvitation projectInvitation, Project project, AppUser user, string token)
        {
            projectInvitation.Email     = user.Email;
            projectInvitation.ProjectId = project.ProjectId;
            projectInvitation.token     = token;

            context.ProjectInvitations.Add(projectInvitation);
            int saveResult = await context.SaveChangesAsync();

            return(saveResult == 1);
        }
Beispiel #4
0
        public async Task <IActionResult> Remove(string id)
        {
            var user = await userManager.FindByIdAsync(id);


            //context.Projects.RemoveRange(user);

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

            var userProjects = context.UserProjects.Where(x => x.UserId == id);

            context.UserProjects.RemoveRange(userProjects);

            var authorProjects = context.Projects.Where(x => x.Author.Id == user.Id);

            context.Projects.RemoveRange(authorProjects);

            await context.SaveChangesAsync();

            await userManager.DeleteAsync(user);

            return(RedirectToAction("Index"));
        }
Beispiel #5
0
        public async Task <IActionResult> Remove(int id)
        {
            //Not done
            Project userProject = await context.Projects.FindAsync(id);


            context.Projects.Remove(userProject);
            await context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <bool> ReorderColumns(int id, int[] vals)
        {
            int boardId = id;

            int[] columnsId = vals;

            int newSorting = 1;

            foreach (var valid in columnsId)
            {
                var column = await context.BoardColumns.FindAsync(valid);

                column.BoardColumnSorting = newSorting;

                context.BoardColumns.Update(column);

                newSorting += 1;
            }
            int saveResult = await context.SaveChangesAsync();

            return(saveResult == 1);
        }
Beispiel #7
0
        public async Task <bool> CreateBoard(CreateBoard createBoard, Project project, string slug)
        {
            Board board = new Board
            {
                BoardName = createBoard.BoardName,
                BoardSlug = slug,
                Project   = project,
            };

            await context.Boards.AddAsync(board);

            int saveResult = await context.SaveChangesAsync();

            return(saveResult == 1);
        }
        public async Task <IActionResult> Create(ChatMessage messageTemplate)
        {
            AppUser user = await userManager.GetUserAsync(HttpContext.User);

            ChatMessage chatMessage = new ChatMessage
            {
                MessageText = messageTemplate.MessageText,
                Project     = context.Projects.Find(messageTemplate.ProjectId),
                Author      = user,
                AuthorId    = user.Id,
                TimeSent    = DateTime.Now
            };

            await context.ChatMessages.AddAsync(chatMessage);

            await context.SaveChangesAsync();

            return(Ok());
        }