Esempio n. 1
0
        public async Task <IActionResult> PutQuiz(int id, Quiz quiz)
        {
            if (id != quiz.QuizId)
            {
                return(BadRequest(new { message = "fel quiz id" }));
            }

            _context.Update(quiz);

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

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("ProjectId,MemberId")] ProjectMember projectMember)
        {
            if (ModelState.IsValid)
            {
                _context.Add(projectMember);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MemberId"]  = new SelectList(_context.AllUsers, "Id", "Name", projectMember.MemberId);
            ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Description", projectMember.ProjectId);
            return(View(projectMember));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("SpecialtyId,UserId")] SpecialtyUser specialtyUser)
        {
            if (ModelState.IsValid)
            {
                _context.Add(specialtyUser);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SpecialtyId"] = new SelectList(_context.Specialties, "Id", "Name", specialtyUser.SpecialtyId);
            ViewData["UserId"]      = new SelectList(_context.AllUsers, "Id", "Name", specialtyUser.UserId);
            return(View(specialtyUser));
        }
        public async Task <IActionResult> AddSpecialty(long specId, long id)
        {
            var  userEmail = User.Identity.Name;
            User user      = await _context.Users.FirstOrDefaultAsync(u => u.Email == userEmail);

            var specialty = await _context.Specialties.FirstOrDefaultAsync(c => c.Id == specId);

            var specialtyUser = await _context.SpecialityUsers.FirstOrDefaultAsync(b => b.UserId == user.Id && b.SpecialtyId == specId);

            if (specialtyUser == null)
            {
                _context.SpecialityUsers.Add(new SpecialtyUser {
                    UserId = user.Id, SpecialtyId = specId
                });
                await _context.SaveChangesAsync();
            }
            return(RedirectToAction("EditSpecialties", new RouteValueDictionary(
                                        new { controller = "Account", action = "EditSpecialties", Id = user.Id })));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(ProjectViewModel model)
        {
            var  userEmail = User.Identity.Name;
            User user      = await _context.Users.FirstOrDefaultAsync(u => u.Email == userEmail);

            Project project = new Project()
            {
                OwnerId = user.Id, Name = model.Project.Name, Description = model.Project.Description
            };

            _context.Projects.Add(project);
            await _context.SaveChangesAsync();

            _context.ProjectMembers.Add(new ProjectMember {
                ProjectId = project.Id, MemberId = user.Id
            });
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Project"));
        }
Esempio n. 6
0
 public void Delete(int id)
 {
     try
     {
         Events events = dbContext.Events.FirstOrDefault(u => u.EId.Equals(id));
         dbContext.Events.Remove(events);
         dbContext.SaveChangesAsync();
     }
     catch (Exception e)
     {
     }
 }
Esempio n. 7
0
 public Task Save()
 {
     return(_context.SaveChangesAsync());
 }