Exemplo n.º 1
0
        public IActionResult JionOrder(CodeInputModel orderId)
        {
            var userId = User.GetAuthUserId();

            this.service.JionOrder(orderId.Code, userId);
            return(this.Ok());
        }
Exemplo n.º 2
0
        public ActionResult InputCode(CodeInputModel model)
        {
            if (model != null && this.ModelState.IsValid)
            {
                if (CheckIfFileExists() == true)
                {
                    string currUser     = currentUserId();
                    var    fileToDelete = db.UserFiles.FirstOrDefault(f => f.FileOwner == currUser);
                    db.UserFiles.Remove(fileToDelete);
                }

                var file = new UserFile()
                {
                    FileName    = model.CodeTitle,
                    FileDate    = DateTime.Now,
                    FileOwner   = User.Identity.GetUserId(),
                    FileContent = ConvertStringToByte(model.CodeContent)
                };

                db.UserFiles.Add(file);
                db.SaveChanges();

                this.AddNotification("SUCCESS! Code has been submitted.", NotificationType.SUCCESS);
                return(RedirectToAction("Scanning", "Scan"));
            }

            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutAsync(int id, [FromBody] CodeInputModel value)
        {
            if (value == null)
            {
                return(BadRequest("Invalid input"));
            }

            var result = await _codesService.UpdateAsync(id, value);

            if (result == null)
            {
                return(BadRequest($"Update of code {id} failed"));
            }

            return(Ok(result));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PostAsync([FromBody] CodeInputModel value)
        {
            if (value == null)
            {
                return(BadRequest("Invalid input"));
            }

            var result = await _codesService.AddAsync(value);

            if (result == null)
            {
                return(BadRequest("Code not inserted"));
            }

            return(CreatedAtRoute("CodeGetAsync",
                                  new
            {
                id = result.Id
            },
                                  result));
        }