示例#1
0
        public async Task UpdateTask(HRTask task)
        {
            var taskJson =
                new StringContent(JsonSerializer.Serialize(task), Encoding.UTF8, "application/json");

            await _httpClient.PutAsync("api/task", taskJson);
        }
        public HRTask AddTask(HRTask task)
        {
            var addedEntity = _appDbContext.Tasks.Add(task);

            _appDbContext.SaveChanges();
            return(addedEntity.Entity);
        }
示例#3
0
        protected void AddTask()
        {
            HRTask task = new HRTask {
                EmployeeId = Employee.EmployeeId
            };

            Employee.HRTasks.Add(task);
            StateHasChanged();
        }
示例#4
0
        protected override async Task OnInitializedAsync()
        {
            Employees = (await EmployeeDataService.GetAllEmployees()).ToList();
            Task      = new HRTask {
                Status = HRTaskStatus.Open
            };

            var employee = Employees.FirstOrDefault(e => e.Email.ToLower() == User?.Identity?.Name?.ToLower());

            Task.EmployeeId = employee?.EmployeeId;
        }
示例#5
0
        public async Task <HRTask> AddTask(HRTask task)
        {
            var taskJson =
                new StringContent(JsonSerializer.Serialize(task), Encoding.UTF8, "application/json");

            var response = await _httpClient.PostAsync("api/task", taskJson);

            if (response.IsSuccessStatusCode)
            {
                return(await JsonSerializer.DeserializeAsync <HRTask>(await response.Content.ReadAsStreamAsync()));
            }

            return(null);
        }
示例#6
0
        public HRTask UpdateTask(HRTask task)
        {
            var foundTask = _appDbContext.Tasks.FirstOrDefault(e => e.HRTaskId == task.HRTaskId);

            if (foundTask != null)
            {
                foundTask.EmployeeId  = task.EmployeeId;
                foundTask.Description = task.Description;
                foundTask.Status      = task.Status;
                foundTask.Title       = task.Title;
                _appDbContext.SaveChanges();
                return(foundTask);
            }
            return(null);
        }
示例#7
0
        public IActionResult Post(HRTask task)
        {
            if (task == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var createdTask = _taskRepository.AddTask(task);

            return(Created("Task", createdTask));
        }
示例#8
0
        public IActionResult UpdateTask([FromBody] HRTask task)
        {
            if (task.HRTaskId > 0)
            {
                var taskToUpdate = _taskRepository.GetTaskById(task.HRTaskId);

                if (taskToUpdate == null)
                {
                    return(NotFound());
                }

                var updatedTask = _taskRepository.UpdateTask(task);
                if (updatedTask == null)
                {
                    return(NotFound());
                }
                return(NoContent()); //success
            }
            return(BadRequest());
        }
 protected override async Task OnInitializedAsync()
 {
     if (HRTaskId > 0)
     {
         try
         {
             Task = (await TaskDataService.GetTaskById(HRTaskId));
         }
         catch (System.Exception exception)
         {
             Message = exception.Message;
         }
     }
     else
     {
         Task = new HRTask {
             Status = HRTaskStatus.Open
         };
     }
     Employees = (await EmployeeDataService.GetAllEmployees()).ToList();
 }
示例#10
0
 protected void DeleteTask(HRTask task)
 {
     Employee.HRTasks.Remove(task);
     TaskDataService.DeleteTask(task.HRTaskId);
     StateHasChanged();
 }
示例#11
0
        public HRTask GetTaskById(int TaskId)
        {
            HRTask task = _appDbContext.Tasks.FirstOrDefault(c => c.HRTaskId == TaskId);

            return(task);
        }