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); }
protected void AddTask() { HRTask task = new HRTask { EmployeeId = Employee.EmployeeId }; Employee.HRTasks.Add(task); StateHasChanged(); }
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; }
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); }
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); }
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)); }
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(); }
protected void DeleteTask(HRTask task) { Employee.HRTasks.Remove(task); TaskDataService.DeleteTask(task.HRTaskId); StateHasChanged(); }
public HRTask GetTaskById(int TaskId) { HRTask task = _appDbContext.Tasks.FirstOrDefault(c => c.HRTaskId == TaskId); return(task); }