public async Task <IActionResult> Edit(string id, [Bind("User_id,User_name,Fans_num,Blog_num,Comment_num,User_pwd,Avatar")] mb_user mb_user) { if (id != mb_user.User_id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mb_user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!mb_userExists(mb_user.User_id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(mb_user)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,User_publish,User_accept,Create_time,content,blog_id,comment_id")] mb_comment mb_comment) { if (id != mb_comment.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mb_comment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!mb_commentExists(mb_comment.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(mb_comment)); }
//订阅事件 public async Task <IActionResult> Subscribe([Bind("ID,UserA_id,UserB_id")] mb_relationship relationship, string userid, string blogid) { _context.Add(relationship); await _context.SaveChangesAsync(); //被订阅者粉丝数量加1 var mb_user = await _context.mb_user.SingleOrDefaultAsync(m => m.User_id == userid); mb_user.Fans_num++; try { _context.Update(relationship); await _context.SaveChangesAsync(); } catch { } return(RedirectToAction("Details", "blog", new { id = blogid, createid = userid })); }
public void UpdateUser(User user) { _context.Update(user); _context.SaveChanges(); }
public async Task UpdateAsync(TEntity entity) { _context.Update(entity); await _context.SaveChangesAsync(); }
public async Task UpdateSync(TEntity entity) { using var context = new MyBlogContext(); context.Update(entity); await context.SaveChangesAsync(); }