Esempio n. 1
0
        public async Task <ActionResult> Create([Bind(Include = "Id,ProjectId,Topic,Type,Priority,UserId")] UsersTask usersTask)
        {
            if (ModelState.IsValid)
            {
                await _userTaskService.Add(usersTask);

                return(RedirectToAction("Index"));
            }
            _logger.Warn("Create(). Validation error during task creation.");
            ViewBag.ProjectId = new SelectList(await _projectService.GetAll(), "Id", "Name", usersTask.ProjectId);
            ViewBag.UserId    = new SelectList(await _userService.GetAll(), "Id", "UserLogin", usersTask.UserId);
            return(View(usersTask));
        }
Esempio n. 2
0
        public async Task <IActionResult> Post([FromBody] params UserTaskDto[] userTaskDtos)
        {
            try
            {
                var userTasks = _mapper.Map <UserTask[]>(userTaskDtos);
                var addResult = await _userTaskService.Add(userTasks);

                if (addResult.Success)
                {
                    return(StatusCode(StatusCodes.Status200OK));
                }

                return(StatusCode(StatusCodes.Status400BadRequest, addResult.Message));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);

                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }