public IActionResult Delete(DelObj delObj) { for (int i = 0; i < delObj.Id.Count(); i++) { var obj = _context.Driver.Find(delObj.Id[i]); if (obj == null) { return(NotFound()); } _context.Driver.Remove(obj); _context.SaveChanges(); } return(NoContent()); }
public IActionResult Delete(DelObj delObj) { List <InspectTask> delList = new List <InspectTask>(); for (int i = 0; i < delObj.gId.Count(); i++) { var obj = _context.InspectTask.Find(delObj.gId[i]); if (obj == null) { return(NotFound()); } delList.Add(obj); } _context.InspectTask.RemoveRange(delList); _context.SaveChanges(); return(NoContent()); }
public IActionResult Delete(DelObj delObj) { // 获取当前登录用户名 string _currentUserName = CommonService.GetCurrentUser(HttpContext).UserName; for (int i = 0; i < delObj.Id.Count(); i++) { var obj = _context.User.Find(delObj.Id[i]); if (obj == null) { return(NotFound()); } // 系统管理员或者自己不可以删除 if (!(obj.UserName.Equals("admin") || obj.UserName.Equals(_currentUserName))) { _context.User.Remove(obj); _context.SaveChanges(); } } return(NoContent()); }
public IActionResult Delete(DelObj delObj) { // 获取当前登录用户名 string _currentUserName = CommonService.GetCurrentUser(HttpContext).UserName; for (int i = 0; i < delObj.Id.Count(); i++) { var obj = _context.WorkTicket.Find(delObj.Id[i]); if (obj == null) { return(NotFound()); } obj.IsDeleted = true; obj.Status = WorkTicketStatus.已删除.ToString(); obj.Description = obj.Description + "\n【删除工单】操作人:" + _currentUserName + ",时间:" + DateTime.Now; obj.LastUpdateTime = DateTime.Now; obj.LastUpdateUser = _currentUserName; _context.WorkTicket.Update(obj); _context.SaveChanges(); } return(NoContent()); }