Ejemplo n.º 1
0
        public async Task <IActionResult> Register([Bind("ID, Password")] User user)
        {
            if (ModelState.IsValid && UserExists(user.ID))
            {
                _context.User.Add(user);
                int judgement = await _context.SaveChangesAsync();

                return(Json(new Result(judgement)));
            }
            return(Json(new Result(0)));
        }
Ejemplo n.º 2
0
 public async Task UpdateOpenNumber()
 {
     _logger.LogDebug("定时任务运行");
     if (this.UpdateOpenNumbers())
     {
         _context.UserOpenInformation.RemoveRange(_context.UserOpenInformation);
         await _context.SaveChangesAsync();
     }
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> OpenDoor([FromBody] JObject json)
        {
            if (ModelState.IsValid)
            {
                var equipmentID     = json["equipmentid"].Value <string>();
                var openNumber      = json["opennumber"].Value <int>();
                var equipment       = _context.Equipment.Find(equipmentID);
                var openInformation = _context.UserOpenInformation.Find(openNumber);
                if (equipment != null && openInformation != null && !openInformation.Result)
                {
                    equipment.WorkingTime++;
                    openInformation.Equipment   = equipment;
                    openInformation.EquipmentID = equipment.EquipmentID;
                    openInformation.Time        = DateTime.Now;
                    openInformation.Result      = true;
                    await _context.SaveChangesAsync();

                    return(Json(new Result(1)));
                }
            }
            return(Json(new Result(0)));
        }