Beispiel #1
0
        public TaskModel Post([FromBody] TaskModel taskModel)
        {
            var task = _mapper.Map <TaskModel, Task>(taskModel);

            _taskService.AddTask(task);
            return(taskModel);
        }
Beispiel #2
0
        public ActionResult Post([FromBody] CreateTaskRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            else
            {
                var itemExists = _taskService.Tasks.Any(i => i.Title == request.TaskTitle && i.TaskListId == request.TaskListId && i.IsDeleted != true);

                if (itemExists && IsUserOrTaskListInactive(request.TaskListId))
                {
                    return(BadRequest());
                }
                Models.Task item = new Models.Task();
                item.TaskListId   = request.TaskListId;
                item.TaskId       = Guid.NewGuid().ToString().Replace("-", "");;
                item.CreatedOnUtc = DateTime.UtcNow;
                item.UpdatedOnUtc = DateTime.UtcNow;
                item.Title        = request.TaskTitle;

                _taskService.AddTask(item);

                var tasks       = _taskService.Tasks.Where(i => i.TaskListId == request.TaskListId && i.IsDeleted != true).Select(p => new { Title = p.Title }).ToList();
                var getTaskList = _taskService.TaskLists.Where(i => i.TaskListId == request.TaskListId).SingleOrDefault();
                var user        = _taskService.Users.Where(u => u.userId == getTaskList.UserId).SingleOrDefault();
                return(Json(new { User = user.EmailAddress, Tasks = tasks, TaskList = getTaskList.Title }));
            }
        }
Beispiel #3
0
        private TaskDTO Create(TaskViewModel viewModel)
        {
            try
            {
                log.Debug(TaskViewModel.FormatTaskViewModel(viewModel));

                TaskDTO task = new TaskDTO();

                // copy values
                viewModel.UpdateDTO(task, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                task.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                task.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_taskService.AddTask - " + TaskDTO.FormatTaskDTO(task));

                int id = _taskService.AddTask(task);

                task.TaskId = id;

                log.Debug("result: 'success', id: " + id);

                return(task);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
        public IActionResult Create(TaskViewModel data)
        {
            data.TaskName     = HtmlEncoder.Default.Encode(data.TaskName);
            data.Deadline     = data.Deadline;
            data.TeacherEmail = User.Identity.Name;

            if (ModelState.IsValid)
            {
                if (data.Deadline > DateTime.Now)
                {
                    _taskService.AddTask(data);

                    TempData["message"] = "Task Created Successfully";
                    return(View());
                }
                else
                {
                    TempData["error"] = "Deadline cant be in the past";
                    return(View());
                }
            }
            else
            {
                ModelState.AddModelError("", "Check your input. Operation failed");
                return(View(data));
            }
        }
Beispiel #5
0
        public async Task <IActionResult> Post([FromBody] TaskModel taskModel)
        {
            taskModel.CreatedBy = 1;
            var task = _outputConverter.Map <Domain.Task.Task>(taskModel);
            await _taskService.AddTask(task);

            return(Ok());
        }
 public IActionResult AddTask([FromBody] Task task)
 {
     if (task != null)
     {
         _service.AddTask(task);
     }
     return(Ok());
 }
Beispiel #7
0
 public IActionResult AddNewTask(AddTaskDTO model)
 {
     if (ModelState.IsValid)
     {
         var data = _taskService.AddTask(model);
         return(Ok("New Task Created Successfuly with Id = " + data));
     }
     return(BadRequest(ModelState));
 }
 public IActionResult Add([FromBody] TaskChangeHistoryDTO taskChangeHistoryDTO)
 {
     if (taskChangeHistoryDTO == null)
     {
         return(StatusCode(400));
     }
     _taskServise.AddTask(taskChangeHistoryDTO);
     return(Ok(taskChangeHistoryDTO));
 }
        public IHttpActionResult CreateTask(TaskDetailCreateDto dto)
        {
            if (dto == null)
            {
                return(BadRequest("Test"));
            }


            return(Ok(_taskService.AddTask(dto)));
        }
Beispiel #10
0
        public ActionResult <TaskDTO> CreateTaskForList([FromBody] TaskToCreateDTO task)
        {
            try
            {
                if (!_listService.Exist(task.IdList))
                {
                    return(NotFound());
                }

                var dbTask = _mapper.Map <Data.DbModels.TTask>(task);
                _taskService.AddTask(task.IdList, dbTask);

                var taskToReturn = _mapper.Map <TaskDTO>(dbTask);
                return(Ok(taskToReturn));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
Beispiel #11
0
        public async Task <IActionResult> PostAssignTask([FromBody] AssignTaskVM assignTaskVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _taskService.AddTask(assignTaskVM);

            return(CreatedAtAction("GetAssignTask", new { id = assignTaskVM.TaskId }, assignTaskVM));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            await _taskService.AddTask(TaskModel);

            return(RedirectToPage("./Index"));
        }
Beispiel #13
0
 private void AddTask()
 {
     if (!string.IsNullOrWhiteSpace(NewTaskText))
     {
         Tasks = _taskService.AddTask(new Task()
         {
             Name = NewTaskText
         });
     }
     NewTaskText = string.Empty;
 }
        public ActionResult Post([FromBody] TaskDTO task)
        {
            if (task.ParentTaskId == 0)
            {
                task.ParentTaskId = null;
            }
            task.UserId = null;

            _tservice.AddTask(task);
            _tservice.Save();
            return(Ok(true));
        }
 public OkResult AddTask(long project_id, [FromBody] TaskDetailsDTO details, string username)
 {
     details.Users = new List <string>()
     {
         username
     };
     details.TimeLog = new List <TimeLogDTO>();
     service.AddTask(new User {
         Username = username
     }, project_id, details.ToEntity());
     return(Ok());
 }
Beispiel #16
0
 public IActionResult AddTask([FromBody] Task task)
 {
     try
     {
         var response = _taskService.AddTask(task);
         return(Ok(response));
     }
     catch (Exception exception)
     {
         return(BadRequest(exception.Message));
     }
 }
 public IActionResult Add(TaskVm task, string token)
 {
     if (task == null)
     {
         return(Ok(ResponseManager.GenerateResponse("Błąd: podane zadanie jest puste", (int)MessageType.Error, null)));
     }
     else
     {
         var idTask = _taskService.AddTask(task);
         task.IdTask = idTask;
         return(Ok(ResponseManager.GenerateResponse(null, (int)MessageType.Ok, task)));
     }
 }
 private async void SaveAsync()
 {
     if (Create)
     {
         Task.Id = Guid.NewGuid().ToString();
         await _taskService.AddTask(Task);
     }
     else
     {
         await _taskService.UpdateTask(Task.Id, Task);
     }
     await NavigationService.NavigateBackAsync();
 }
Beispiel #19
0
        public override ActionTaskResult Process(ActionContext context)
        {
            var productIds = _freezeService.GetUnfrozenProductIds();

            if (productIds.Any())
            {
                int productContentId = int.Parse(_settingsService.GetSetting(SettingsTitles.PRODUCTS_CONTENT_ID));

                var publishContext = new ActionContext
                {
                    BackendSid     = context.BackendSid,
                    CustomerCode   = context.CustomerCode,
                    ContentId      = productContentId,
                    ContentItemIds = productIds,
                    Parameters     = context.Parameters,
                    UserId         = context.UserId,
                    UserName       = context.UserName,
                };

                /*
                 * string actionAdapter = null;
                 * context.Parameters.TryGetValue(AdapterKey, out actionAdapter);
                 * var publishAction = _getAction(PublishAction, actionAdapter);
                 * publishAction.Process(publishContext);
                 */

                var dataForQueue = new ActionData
                {
                    ActionContext = publishContext,
                    Description   = null,
                    IconUrl       = null
                };

                string data = ActionData.Serialize(dataForQueue);

                _taskService.AddTask(PublishAction, data, publishContext.UserId, publishContext.UserName, TaskStrings.Unfreezing);

                return(ActionTaskResult.Success(new ActionTaskResultMessage()
                {
                    ResourceClass = nameof(TaskStrings),
                    ResourceName = nameof(TaskStrings.ProductsUnfreezed),
                    Extra = string.Join(", ", productIds)
                }));
            }

            return(ActionTaskResult.Success(new ActionTaskResultMessage()
            {
                ResourceClass = nameof(TaskStrings),
                ResourceName = nameof(TaskStrings.NoProductsToUnfreeze),
            }));
        }
        public async Task <ActionResult> AddTask([FromBody] ToDoTaskDTO toDoTask)
        {
            if (ModelState.IsValid)
            {
                var result = await taskService.AddTask(toDoTask);

                if (result == null)
                {
                    return(NotFound());
                }
                return(Ok(result));
            }
            return(BadRequest("Not correct query"));
        }
Beispiel #21
0
        public async Task <IHttpActionResult> Post([FromBody] EmployeeTaskDto etask)
        {
            try
            {
                var result = await _taskService.AddTask(etask);

                return(this.JsonDataResult(result));
            }
            catch (Exception e)
            {
                //Logger.Log(LogLevel.Error, e);
                return(new InternalServerErrorResult(this));
            }
        }
        public ActionResult New(Task newTask)
        {
            // Validate model state
            if (!ModelState.IsValid)
            {
                return(View("New", newTask));
            }

            newTask.UserGuid = UserGuid;

            taskService.AddTask(newTask);

            return(RedirectToAction("Detail", new { newTask.Id }));
        }
Beispiel #23
0
        private void EditBtn_Click(object sender, EventArgs e)
        {
            TaskModel newTask = _bindingSourceCurrentTask.Current as TaskModel;
            var       oldTask = _bindingSourceTasks.Current as TaskModel;

            // For a new Task, a new Id is created, this should not be the case,
            // for new task the previous Id from oldTask.
            newTask.Id = oldTask.Id;

            if (comboBox1.SelectedItem != null)
            {
                // Give id the current item in combobox.
                newTask.CategoryId = comboBox1.SelectedValue.ToString();
            }

            if (dataGridView1.CurrentCell.Value == null)
            {
                try
                {
                    _taskService.AddTask(newTask);
                    panel1.Visible = false;
                    MessageBox.Show($"The task \"{newTask.Name}\" added.");
                    dataGridView1.Visible = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                try
                {
                    _taskService.UpdateTask(newTask);
                    panel1.Visible = false;
                    MessageBox.Show($"The task \"{newTask.Name}\" updated.");
                }
                catch (System.Data.Entity.Core.ObjectNotFoundException ex)
                {
                    MessageBox.Show($"{ex.Message}");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            LoadTasks();
        }
Beispiel #24
0
        public ActionResult AddTask(TaskModel model)
        {
            ViewBag.Detail = false;

            if (ModelState.IsValid)
            {
                model.UserId = Service.GetUserIdByName(User.Identity.Name);
                Service.AddTask(model);
                return(View("TaskList", Service.GetAllTasksById(model.UserId)));
            }
            else
            {
                return(View());
            }
        }
Beispiel #25
0
 public ActionResult Post([FromBody] TaskDto request)
 {
     try
     {
         _taskService.AddTask(request);
         return(Ok("Success"));
     }
     catch (TaskException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public ActionResult Send(string idsStr, bool proceedIgnoredStatus, string[] ignoredStatus, bool stageOnly, bool localize = false)
        {
            int[] ids = null;
            ignoredStatus = ignoredStatus ?? Enumerable.Empty <string>().ToArray();

            ids = idsStr
                  .Split(new[] { ' ', ';', ',', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                  .Select(int.Parse)
                  .Distinct()
                  .ToArray();

            ViewBag.IgnoredStatus = ignoredStatus;
            ViewBag.Localize      = localize;

            int    userId   = _userProvider.GetUserId();
            string userName = _userProvider.GetUserName();

            var parameters = new Dictionary <string, string>();

            if (!proceedIgnoredStatus)
            {
                parameters.Add("IgnoredStatus", string.Join(",", ignoredStatus));
            }

            if (stageOnly)
            {
                parameters.Add("skipPublishing", true.ToString());
                parameters.Add("skipLive", true.ToString());
            }

            parameters.Add("Localize", localize.ToString());

            string taskData = ActionData.Serialize(new ActionData
            {
                ActionContext = new A.ActionContext()
                {
                    ContentItemIds = ids, ContentId = 288, Parameters = parameters, UserId = userId, UserName = userName
                }
            });

            var taskKey = typeof(SendProductAction).Name;
            int taskId  = _taskService.AddTask(taskKey, taskData, userId, userName, TaskStrings.PartialSend);

            return(Json(new { taskId }));
        }
        public async Task <IActionResult> CreateTask(TaskRequestModel taskRequestModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState.Values));
                }
                await _taskService.AddTask(taskRequestModel);

                return(Ok());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(500, e.Message));
            }
        }
Beispiel #28
0
        public IHttpActionResult PostTaskModel(TaskModel taskModel)
        {
            TaskModel taskModel1 = taskService.GetTaskById(taskModel.TaskId);

            if (taskModel1 != null)
            {
                return(BadRequest());
            }

            var result = taskService.AddTask(taskModel);

            if (result != null)
            {
                return(Ok());
            }

            return(BadRequest());
        }
Beispiel #29
0
        public ActionResult Reset(string language, string state)
        {
            if (!Configuration.DataOptions.CanUpdate)
            {
                return(BadRequest("Unable to recreate index. This is read-only instance."));
            }

            var syncer = Configuration.GetSyncer(language, state);

            if (!syncer.AnySlotsLeft)
            {
                return(BadRequest("There is no available slots. Please, wait for previous operations completing."));
            }

            int taskId = _taskService.AddTask("ReindexAllTask", $"{language}/{state}", 0, null, "ReindexAllTask");

            return(Json(new JObject(new JProperty("taskId", taskId))));
        }
Beispiel #30
0
        public async Task <AddTaskResponse> Handle(AddTaskCommand request, CancellationToken cancellationToken)
        {
            DailyTasks dailyTasks = new DailyTasks
            {
                AddedDate     = DateTime.UtcNow,
                Priority      = request.Priority,
                TaskEndTime   = request.TaskEndTime,
                TaskStartTime = request.TaskStartTime,
                Title         = request.Title,
                Owner         = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Email).Value
            };

            await _taskService.AddTask(dailyTasks);

            return(new AddTaskResponse
            {
                Message = "New task has successfully added"
            });
        }