public async Task DeleteUserByIdAsync(string Id) { var user = await _dbContext.Users.FindAsync(Id); _dbContext.Entry(user).Reference(c => c.UserProfile).Load(); _dbContext.Users.Remove(user); }
public async Task <IActionResult> PutTopic(int id, Topic topic) { if (id != topic.Id) { return(BadRequest()); } _context.Entry(topic).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TopicExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static void Main() { using (var context = new ForumDbContext()) { /* Test RegistrationDate - Shadow Property */ //Random random = new Random(); //var users = context.Users.ToList(); //foreach (var user in users) //{ // var seconds = random.Next(-100_000_000, -1); // var randomDate = DateTime.Now.AddSeconds(seconds); // context.Entry(user).Property("RegistrationDate").CurrentValue = randomDate; //} //context.SaveChanges(); /* Order Posts by Shadow Property */ var orderedUsers = context.Users .OrderBy(user => EF.Property <DateTime>(user, "RegistrationDate")) .ToList(); foreach (var user in orderedUsers) { Console.WriteLine(context.Entry(user).Property("RegistrationDate").CurrentValue); } /* Test LastUpdate - Shadow Property */ //var post = context.Posts.Find(1); //post.Title = "Core za Facebook!"; //context.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "Id,Title,Date,Category")] Thread thread) { if (ModelState.IsValid) { db.Entry(thread).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(thread)); }
public ActionResult Edit([Bind(Include = "CategoryId,CategoryName,CategoryDescription")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "Id,Body,Date")] Post post) { if (ModelState.IsValid) { db.Entry(post).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(post)); }
public ActionResult Edit([Bind(Include = "Id,Category")] Forums forums) { if (ModelState.IsValid) { db.Entry(forums).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(forums)); }
public ActionResult Edit([Bind(Include = "CategoryId,Name,Description,ParentId")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ParentId = new SelectList(db.Categories, "CategoryId", "Name", category.ParentId); return(View(category)); }
public ActionResult Edit([Bind(Include = "MessageId,SenderId,ReceiverId,Text,SendDate,Seen")] Message message) { if (ModelState.IsValid) { db.Entry(message).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ReceiverId = new SelectList(db.Users, "Id", "UserName", message.ReceiverId); ViewBag.SenderId = new SelectList(db.Users, "Id", "UserName", message.SenderId); return(View(message)); }
public ActionResult Edit([Bind(Include = "PostId,Body,AuthorId,CreatedTime,ThreadId")] Post post) { if (ModelState.IsValid) { db.Entry(post).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AuthorId = new SelectList(db.Users, "Id", "UserName", post.AuthorId); ViewBag.ThreadId = new SelectList(db.Threads, "ThreadId", "ThreadTitle", post.ThreadId); return(View(post)); }
public ActionResult Edit([Bind(Include = "ThreadId,ThreadTitle,IsPinned,AuthorId,CategoryId")] Thread thread) { if (ModelState.IsValid) { db.Entry(thread).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AuthorId = new SelectList(db.Users, "Id", "UserName", thread.AuthorId); ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", thread.CategoryId); return(View(thread)); }
public async Task <ActionResult <ProfileFull> > UpdateProfile([FromBody] ProfileUpdateForm _userData) { string UserName = this.User.Claims.First(i => i.Type == "UserName").Value; var user = await _context.User.FirstOrDefaultAsync(u => u.UserName == UserName); if (user == null) { return(BadRequest()); } var UserAnswerResponse = new UserAnswer(); UserAnswerResponse.profilefull = new ProfileFull(user); user.Name = _userData.name; user.Surname = _userData.surname; user.Birthdate = _userData.birthdate; user.DisplayName = _userData.displayname; _context.Entry(user).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.UserName)) { return(NotFound()); } else { throw; } } return(Ok(UserAnswerResponse)); }
public ActionResult Editar(Postagem post) { if (AutenticarUsuario.VerificarSessaoUsuario()) { if (ModelState.IsValid) { db.Entry(post).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { idDoTopico = post.IdDoTopico })); } return(View(post)); } return(Redirect("/Login")); }
public ActionResult Editar([Bind(Include = "ID,Nome,Login,Senha,PerfilDoUsuario")] Usuario usuario) { if (AutenticarUsuario.VerificarSessaoUsuario() && AutenticarUsuario.VerificarSessaoUsuario()) { if (ModelState.IsValid) { db.Entry(usuario).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(usuario)); } return(Redirect("/Login")); }
public ActionResult Edit(User user, String role) { if (ModelState.IsValid) { // Stamp so the identity doesn't crash user.SecurityStamp = Guid.NewGuid().ToString(); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); // Delete all roles from user and add new one userManager.GetRoles(user.Id).ForEach(e => userManager.RemoveFromRole(user.Id, e)); userManager.AddToRole(user.Id, role); return(RedirectToAction("Index")); } return(View(user)); }
public void Update(User entity) { db.Entry(entity).State = EntityState.Modified; }
public void Update(Message entity) { _dbContext.Entry(entity).State = EntityState.Modified; }
public void Update(Topic entity) { _dbContext.Entry(entity).State = EntityState.Modified; }
public virtual void Update(T entity) { _dbContext.Entry(entity).State = EntityState.Modified; }
public void Update(Profile item) { context.Entry(item).State = EntityState.Modified; context.SaveChanges(); }
public void Update(T obj) { table.Attach(obj); _context.Entry(obj).State = EntityState.Modified; }
public void Update(Complaint entity) { db.Entry(entity).State = EntityState.Modified; }
public void Update(Topic item) { context.Entry(item).State = EntityState.Modified; }
public void Update(Message entity) { db.Entry(entity).State = EntityState.Modified; }