Ejemplo n.º 1
0
 public async Task <IActionResult> Report(TodoAppViewModel taskReported)
 {
     if (taskReported.Status != "Đã hoàn thành" && taskReported.Description == null)
     {
         ViewBag.ErrorMessage = "Please fill the Description !";
         string[] status = { "Đã hoàn thành", "Sắp hoàn thành", "Chưa hoàn thành" };
         ViewBag.Status = status;
         return(View(await _todoAppService.GetById(taskReported.Id)));
     }
     if (ResponseHasErrors(await _todoAppService.Report(taskReported)))
     {
         return(View(_todoAppService.GetById(taskReported.Id)));
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(TodoAppViewModel todoAppViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(todoAppViewModel));
            }

            if (ResponseHasErrors(await _todoAppService.Register(todoAppViewModel)))
            {
                return(View(todoAppViewModel));
            }

            ViewBag.Sucess = "Task Registered!";

            return(View(todoAppViewModel));
        }
Ejemplo n.º 3
0
 public async Task <IActionResult> Put([FromBody] TodoAppViewModel todoAppViewModel)
 {
     return(ModelState.IsValid ? CustomResponse(await _todoAppService.Update(todoAppViewModel))
         : CustomResponse(todoAppViewModel));
 }
Ejemplo n.º 4
0
 public async Task <IActionResult> Post([FromForm] TodoAppViewModel todoAppViewModel)
 {
     return(ModelState.IsValid ? CustomResponse(await _todoAppService.Register(todoAppViewModel))
         : CustomResponse(todoAppViewModel));
 }
Ejemplo n.º 5
0
        public async Task <ValidationResult> Update(TodoAppViewModel todoAppViewModel)
        {
            var updateCommand = _mapper.Map <UpdateTodoAppCommand>(todoAppViewModel);

            return(await _mediator.SendCommand(updateCommand));
        }
Ejemplo n.º 6
0
        public async Task <ValidationResult> Report(TodoAppViewModel todoAppViewModel)
        {
            var reportCommand = _mapper.Map <ReportTodoAppCommand>(todoAppViewModel);

            return(await _mediator.SendCommand(reportCommand));
        }
Ejemplo n.º 7
0
        public async Task <ValidationResult> Register(TodoAppViewModel todoAppViewModel)
        {
            var registerCommand = _mapper.Map <CreateTodoAppCommand>(todoAppViewModel);

            return(await _mediator.SendCommand(registerCommand));
        }