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)); }
public IActionResult Create(CodeCreate model) { if (ModelState.IsValid) { codeService.Create(model); return(RedirectToAction("Index", "Directory", new { id = model.DirectoryId })); } return(View(model)); }
public IActionResult CreateCode([FromBody] ValueCodeDto valueCodeDto) { try { codeService.Create(valueCodeDto); return Ok(); } catch (Exception) { return BadRequest(); } }
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; } }
public async Task <Code> Post([FromBody] Code code) { return(await _codeService.Create(code)); }