示例#1
0
        public async Task <IActionResult> PostAsync([FromBody] TaskModel task)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (await _service.ExistsAsync(task.Id))
                {
                    await _service.UpdateAsync(task);

                    _logger.LogDebug($"UpdateAsync with Name:'{task.Name}' successful.");
                    await _service.SaveAsync();

                    return(Ok(task));
                }
                else
                {
                    Guid createdTaskId = _service.Add(task);
                    task.Id = createdTaskId;
                    _logger.LogDebug($"Add with Name:'{task.Name}' successful.");
                    await _service.SaveAsync();

                    return(CreatedAtAction(nameof(GetByIdAsync), new { id = createdTaskId }, task));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
示例#2
0
        public IActionResult Task(Task task)
        {
            var userId = User.GetUserId();

            task.UserId = userId;

            if (!ModelState.IsValid)
            {
                var vm = new TaskViewModel()
                {
                    Task       = task,
                    Categories = _categoryService.GetCategories(userId),
                    Heading    = task.Id == 0 ?
                                 "nowe zadanie" :
                                 "edycja zadania"
                };

                return(View("Task", vm));
            }

            if (task.Id == 0)
            {
                _taskService.Add(task);
            }
            else
            {
                _taskService.Update(task);
            }


            return(RedirectToAction("Tasks", "Task"));
        }
示例#3
0
        private void OnConfirmKryptonButtonClickedEventRaised(object sender, EventArgs e)
        {
            try
            {
                string eventCalendar = _addEventView.EventCalendar;

                Event myEvent = new Event
                {
                    Summary  = _addEventView.EventDescription,
                    Location = _addEventView.EventLocation,
                    Start    = _addEventView.EventStartTime,
                    End      = _addEventView.EventEndTime,
                };
                _taskService.Add(eventCalendar, myEvent);
                _addEventView.CloseWindow();
            }
            catch (InvalidEventDataException ex)
            {
                _errorMessageView.ShowErrorMessageView("Error", ex.Message);
            }
            catch (Exception ex)
            {
                _errorMessageView.ShowErrorMessageView("Error", ex.Message);
            }
        }
示例#4
0
        public IActionResult Create(Entities.Concrete.Task task)
        {
            CreateEditTaskViewModel model = null;

            try
            {
                model = new CreateEditTaskViewModel
                {
                    Task      = task,
                    TaskTypes = _taskTypeManager.GetAll(),
                    UserId    = User.Identity.UserId(),
                };
                _taskManager.Add(task);
                return(RedirectToAction(nameof(Index)));
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError("Error", ex.Message);
                return(View(model));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(Error());
            }
        }
示例#5
0
        public TaskEntity Add([FromBody] TaskDto taskDto, int idProject, int idJalon)
        {
            TaskEntity task = new TaskEntity()
            {
                AssigneeId       = taskDto.AssigneeId,
                Label            = taskDto.Label,
                PlannedStartDate = taskDto.PlannedStartDate,
                PlannedEndDate   = taskDto.PlannedStartDate.AddDays(taskDto.Cost),
                RealStartDate    = taskDto.RealStartDate,
                RealEndDate      = taskDto.RealEndDate,
                Cost             = taskDto.Cost,
                Description      = taskDto.Description,
                Exigences        = taskDto.Exigences,
                JalonId          = idJalon,
                RequiredTask     = taskDto.RequiredTaskId,
            };


            UrlConfig config = new UrlConfig()
            {
                IdProject = idProject, IdJalon = idJalon
            };

            return(_TaskService.Add(task, config));
        }
示例#6
0
        public async Task <IActionResult> Create(TaskCreateViewModel vm)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    UserTask task = new UserTask()
                    {
                        Id = vm.Id, Name = vm.Name
                    };

                    await _taskService.Add(task);

                    return(RedirectToAction("Index"));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }

            return(View(vm));
        }
        // POST: api/Task
        public int Post(TaskModel value)
        {
            if (value == null)
            {
                return(0);
            }
            try
            {
                var task = taskService.Add(new TaskDO()
                {
                    EndDate      = value.EndDate,
                    IsParentTask = value.IsParentTask,
                    ParentTask   = value.ParentTask,
                    Priority     = value.Priority,
                    ProjectID    = value.ProjectID,
                    StartDate    = value.StartDate,
                    Status       = value.Status,
                    Task         = value.TaskName,
                    TaskId       = value.TaskId,
                    TaskOwner    = value.TaskOwner
                });

                return(task);
            }
            catch
            {
                return(0);
            }
        }
        public TaskDTO Add(TaskDTO taskDTO)
        {
            var task = _taskMapper.MapperToEntity(taskDTO);

            task.SetTodoList(_todoListService.Get(taskDTO.TodoList.Id));
            task.SetUser(_userService.Get(taskDTO.User.Id));
            return(_taskMapper.MapperToDTO(_taskService.Add(task)));
        }
        public void Should_Add_Task()
        {
            var task = new Task()
            {
                Title = "unit_test_task_titl5",
                Description = "test test test",
                IsCompleted = false,
                StartingDate = DateTime.Now,
                TypeId = 1,
                UserId = 8
            };
            _taskManager.Add(task);

            bool result = _taskManager.GetAll(task.UserId)
                .Any(t => t.Title == task.Title && t.TypeId == task.TypeId && t.Description == task.Description &&t.StartingDate.Date == task.StartingDate.Date);
            Assert.True(result);
        }
示例#10
0
 public IActionResult Post([FromBody] Tasked task)
 {
     if (_taskService.Add(task) > 0)
     {
         return(Ok(new { status = true, Data = task, Message = "Save Success!" }));
     }
     return(Ok(new { status = false, Data = (string)null, Message = "Error Success!" }));
 }
示例#11
0
 public IActionResult Create([Bind("Title,Description")] ApplicationCore.Entity.Task task)
 {
     if (ModelState.IsValid)
     {
         _taskService.Add(task);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(task));
 }
示例#12
0
        public ActionResult CreateTask([FromBody] AddProjectTaskDto task)
        {
            if (task == null)
            {
                return(BadRequest());
            }

            var addedTask = _taskService.Add(task);

            return(CreatedAtAction("CreateTask", new { id = addedTask.Id }, addedTask));
        }
示例#13
0
        public IActionResult Create([FromForm] TaskDTO item)
        {
            if (ModelState.IsValid)
            {
                _TaskService.Add(item);
                return(RedirectToAction(nameof(Index)));
            }

            ConfigureViewData();
            return(View(item));
        }
示例#14
0
        public IActionResult Post([FromBody] TaskDTO taskDTO)
        {
            if (TaskExists(taskDTO.Id))
            {
                return(BadRequest());
            }

            _TaskService.Add(taskDTO);

            return(Ok(taskDTO));
        }
示例#15
0
        public ActionResult PostTask(eSektorEntities.Task tsk)
        {
            var user   = User.Identity.Name;
            var member = _ms.GetMemberByUsername(user);

            tsk.TaskId   = Guid.NewGuid();
            tsk.MemberId = member.Data.MemberId;//olmzssa bu atamayı view de yap
            var result = _ts.Add(tsk);

            ViewBag.Sonuc       = result.Message;
            ViewBag.SonucDurumu = result.State;
            return(View(tsk));
        }
示例#16
0
 public IHttpActionResult Post([FromBody] NewTaskDTO dto)
 {
     if (dto == null)
     {
         return(BadRequest());
     }
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     _service.Add(dto);
     return(Ok(""));
 }
示例#17
0
    public async Task <IActionResult> New([FromBody] string description)
    {
        try
        {
            var id = await _service.Add(description);

            return(Ok(id));
        }
        catch (Exception error)
        {
            return(BadRequest(error.Message));
        }
    }
示例#18
0
        public ActionResult Create(TaskViewModel task)
        {
            if (!User.IsInRole("Master"))
            {
                task.UserID = GetUserIdentityID();
            }

            try
            {
                if (ModelState.IsValid)
                {
                    //valida se usuário possui outras tarefas em produção.
                    bool userTasksInProduction = this.validateUserTasksInProduction(task.UserID, (Enums.EnumTaskStatus)task.StatusID);

                    if (userTasksInProduction)
                    {
                        ModelState.AddModelError("", "Cada usuário só pode ter uma tarefa [Em produção] por vez.");
                    }
                    //validação para UserID não consta na ViewModel.
                    else if (!task.UserID.HasValue)
                    {
                        ModelState.AddModelError("UserID", "Preencha o campo usuário.");
                    }
                    else
                    {
                        var newTask = Mapper.Map <TaskViewModel, TB_Task>(task);
                        _taskService.Add(newTask);

                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Erro ao criar tarefa. ERRO: " + ex.Message);
            }


            if (User.IsInRole("Master"))
            {
                ViewBag.UserID = new SelectList(_userService.GetAll(), "ID", "Name", task.UserID);
            }
            else
            {
                ViewBag.UserID = GetUserIdentityID().ToString();
            }

            ViewBag.StatusID = new SelectList(_taskStatusService.GetAll(), "ID", "Status", task.StatusID);

            return(View(task));
        }
示例#19
0
        public ActionResult Create([Bind(Exclude = "User")] TaskMetadata task)
        {
            var  identity = User.Identity.Name;
            User user     = userService.FindByEmail(identity);

            task.User   = user;
            task.UserID = user.UserID;


            taskService.Add(task);


            return(RedirectToAction("Index"));
        }
示例#20
0
 public IActionResult AddTask(TaskAddDto model)
 {
     if (ModelState.IsValid)
     {
         var entity = _mapper.Map <TaskEntity>(model);
         _taskService.Add(entity);
         return(RedirectToAction("Index"));
     }
     else
     {
         ViewBag.Urgencies = new SelectList(_urgencyService.GetAll(), "Id", "Description");
     }
     return(View(model));
 }
示例#21
0
        private void AddClicked(object sender, RoutedEventArgs e)
        {
            if (isValidValues())
            {
                if (tasksList.SelectedItem.ToString().Equals("Cleaning"))
                {
                    roomService.UpdateStatus("Unclean", roomService.Find((int)roomsList.SelectedItem));
                }

                var task = taskService.CreateTask(tasksList.SelectedItem.ToString(), (int)roomsList.SelectedItem, description.Text);
                taskService.Add(task);
                this.Close();
            }
        }
示例#22
0
 public IActionResult Create(TaskModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = mapper.Map <Tasks>(model);
         entity.UserID = GetUserID();
         service.Add(entity);
         return(View("Index"));
     }
     else
     {
         return(View(model));
     }
 }
        public void Add()
        {
            Task task = new Task
            {
                Details       = "Test details",
                EstimatedDate = DateTime.Now,
                Notes         = "Test notes",
                ProjectId     = 1,
                TaskStateId   = 4
            };
            var result = _taskService.Add(task);

            Assert.AreEqual(true, result.IsSuccessful);
        }
示例#24
0
        public ActionResult Index(TaskModel model)
        {
            var result = _taskService.Add(model);

            if (result != 0)
            {
                TempData["recordStatus"] = true;
            }
            else
            {
                TempData["recordStatus"] = false;
            }

            return(RedirectToAction("index"));
        }
 public IActionResult AddTask(TaskAddViewModel model)
 {
     TempData["active"] = "task";
     if (ModelState.IsValid)
     {
         _taskService.Add(new Task_Entity
         {
             Description = model.Description,
             Name        = model.Name,
             UrgencyId   = model.UrgencyId
         });
         return(RedirectToAction("index"));
     }
     return(View(model));
 }
示例#26
0
        public ActionResult Save([FromBody] TaskModel item)
        {
            try
            {
                var task   = _mapper.Map <TaskItem>(item);
                var result = _service.Add(task);
                return(Ok(result));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(BadRequest());
        }
        public IActionResult Post([FromBody] TaskModel task)
        {
            var addedTask = _service.Add(new Business.Service.DTOs.Task.TaskDto
            {
                Title   = task.Title,
                StateId = task.StateId
            });

            if (addedTask == null)
            {
                return(UnprocessableEntity());
            }

            return(Created(new Uri($"{Request.Scheme}://{Request.Host}{Request.Path}/{addedTask.Id}"), addedTask));
        }
示例#28
0
        public void TaskServiceShouldAddNewTask()
        {
            var _newTask = new Task()
            {
                Title       = "Test Task 12",
                CreateDate  = DateTime.Parse("2019-09-25"),
                Description = "description of test task 12",
                StaffNo     = 1001
            };

            int maxTaskNo = _tasks.Max(t => t.TaskNo);

            _newTask.TaskNo = maxTaskNo + 1;
            _taskService.Add(_newTask);

            Assert.That(_newTask, Is.EqualTo(_tasks.Last()));
        }
        public async Task <IActionResult> Add(TaskDto dto)
        {
            var terminal = await terminalService.Find(x => x.Sim == dto.SimNumber);

            dto.Terminals = new List <TerminalDto> {
                new TerminalDto {
                    Id = terminal.Id
                }
            };
            var result = await currentservice.Add(dto) > 0;

            return(Ok(new JsonResultDto <bool>
            {
                Data = result,
                Message = result ? null : "操作失败"
            }));
        }
示例#30
0
        public async Task <IHttpActionResult> PostTaskItem(TaskItem taskItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await _taskService.Add(taskItem);
            }
            catch (Exception e)
            {
                InternalServerError(e);
            }

            return(CreatedAtRoute("DefaultApi", new { id = taskItem.Id }, taskItem));
        }