public async Task <IActionResult> Edit(long id, [Bind("ProjectId,MemberId")] ProjectMember projectMember) { if (id != projectMember.ProjectId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(projectMember); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectMemberExists(projectMember.ProjectId)) { return(NotFound()); } else { throw; } } 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)); }
public async Task <IActionResult> Edit(long id, [Bind("SpecialtyId,UserId")] SpecialtyUser specialtyUser) { if (id != specialtyUser.SpecialtyId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(specialtyUser); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpecialtyUserExists(specialtyUser.SpecialtyId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SpecialtyId"] = new SelectList(_context.Specialties, "Id", "Name", specialtyUser.SpecialtyId); ViewData["UserId"] = new SelectList(_context.AllUsers, "Id", "Id", specialtyUser.UserId); return(View(specialtyUser)); }
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()); }
// PUT api/<controller>/5 //[HttpPut("{id}")] public string Put([FromBody] Events value) { Events events = dbContext.Events.Where(u => u.EId.Equals(value.EId)).First(); //events.EId = value.EId; //events.CId = value.CId; events.Title = value.Title; events.Description = value.Description; events.Date = value.Date; try { dbContext.Update(events); dbContext.SaveChanges(); return(JsonConvert.SerializeObject("User has been registered!")); } catch (Exception ex) { return(JsonConvert.SerializeObject(ex.Message)); } }