示例#1
0
        public async Task <IActionResult> Create([Bind("Id,EnlistDate,TournementId,AspNetUsersId")] ContestentsCreateEditModelView contestentsCreateEditModelView)
        {
            if (ModelState.IsValid)
            {
                _appContext.Add(contestentsCreateEditModelView);
                await _appContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contestentsCreateEditModelView));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Name,RegistrationStartDate,RegistrationEndDate,TournementStartDate,TournementEndDate")] Tournement tournement)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tournement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tournement));
        }
        public async Task <IActionResult> AddToProjectAsync([FromBody] AddToProjectViewModel model)
        {
            if (model.Email == null)
            {
                return(BadRequest());
            }

            var user = await _userManager.FindByEmailAsync(model.Email);

            // TODO: CHECK IF IN LIST AND SEND FAILURE

            if (user != null)
            {
                var result = new ProjectMember
                {
                    Employee           = user,
                    IsCreator          = false,
                    AcceptedInvitation = false,
                    ProjectId          = model.ProjectId,
                    ShowOnlyMine       = false
                };

                _context.Add(result);
                if (_context.SaveChanges() > 0)
                {
                    return(new JsonResult("success"));
                }
                else
                {
                    return(BadRequest());
                }
            }
            return(NotFound());
        }
        public async Task <IActionResult> NewPost(NewPostViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                var post = new Post
                {
                    Title       = model.Title,
                    Message     = model.Message,
                    CreatedTime = DateTime.Now,
                    Employee    = user,
                    IsImportant = model.IsImportant
                };
                _context.Add(post);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Posts"));
            }

            return(View(model));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("Id,Name,RegistrationStartDate,RegistrationEndDate,TournementStartDate,TournementEndDate")] TournementViewModel model)
        {
            var tournement = new Tournement();

            if (ModelState.IsValid)
            {
                tournement.Id   = model.Id;
                tournement.Name = model.Name;
                tournement.RegistrationEndDate   = model.RegistrationEndDate;
                tournement.RegistrationStartDate = model.RegistrationStartDate;
                tournement.TournementEndDate     = model.TournementEndDate;
                tournement.TournementStartDate   = model.TournementStartDate;
                _context.Add(tournement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tournement));
        }
        public async Task <IActionResult> Post(NewCommentViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                var result = new Comment
                {
                    CommentText = model.WrittenText,
                    CommentDate = DateTime.Now,
                    PostId      = model.PostId,
                    FullName    = $"{user.Name} {user.Surname}"
                };

                _context.Add(result);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Post"));
            }
            return(View());
        }