Ejemplo n.º 1
0
        public IActionResult Create(string id, int player)
        {
            var device = _deviceService.Get(id);

            if (device == null)
            {
                return(new NotFoundObjectResult(false));
            }

            // var expiredCodes = _codeService.GetAll().Where(x => x.CreatedDate < DateTime.Now.AddMinutes(-10));
            // foreach(var c in expiredCodes) {
            //     _codeService.Delete(c);
            // }

            var digits = "";
            var r      = new Random();

            for (var i = 0; i < 7; i++)
            {
                digits += r.Next(10);
            }
            var code = _codeService.Create(new Code()
            {
                Device      = device,
                Digits      = digits,
                Player      = player,
                CreatedDate = DateTime.Now
            });

            return(new OkObjectResult(digits));
        }
Ejemplo n.º 2
0
        public IActionResult Create(CodeCreate model)
        {
            if (ModelState.IsValid)
            {
                codeService.Create(model);
                return(RedirectToAction("Index", "Directory", new { id = model.DirectoryId }));
            }

            return(View(model));
        }
Ejemplo n.º 3
0
        public IActionResult CreateCode([FromBody] ValueCodeDto valueCodeDto)
        {
            try
            {
                codeService.Create(valueCodeDto);

                return Ok();
            }
            catch (Exception)
            {
                return BadRequest();
            }
        }
Ejemplo n.º 4
0
 protected override void OnBtnCommand(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (e.Item.Caption == BtnCommandEnum.Save)
     {
         eRPC001CodeBindingSource.EndEdit();
         var tempData = eRPC001CodeBindingSource.DataSource as ERP_C001_Code;
         if (this.Tag.ToString() == BtnCommandEnum.Add)
         {
             codeService.Create(tempData);
         }
         else if (this.Tag.ToString() == BtnCommandEnum.Edit)
         {
             codeService.Update(tempData);
         }
         DialogResult = DialogResult.OK;
     }
     if (e.Item.Caption == BtnCommandEnum.Cancel)
     {
         DialogResult = DialogResult.Cancel;
     }
 }
Ejemplo n.º 5
0
 public async Task <Code> Post([FromBody] Code code)
 {
     return(await _codeService.Create(code));
 }