public async Task <IActionResult> UpdateLog(int id, LogToUpdateDto logToUpdate) { var log = await _service.UpdateLog(id, logToUpdate); if (log == null) { return(StatusCode(400)); } return(StatusCode(200, log)); }
public async Task <LogDto> UpdateLog(int logId, LogToUpdateDto updatedLog) { TimeLog logToUpdate = await _context.TimeLogs.FirstOrDefaultAsync(x => x.Id == logId); logToUpdate.ProjectId = updatedLog.ProjectId; logToUpdate.Description = updatedLog.Description; logToUpdate.StartDate = updatedLog.StartTime; logToUpdate.EndDate = updatedLog.StopTime; return(ConvertToLogDto(await UpdateAsync(logToUpdate))); }
public async Task <LogDto> UpdateLogByIdAsync(LogToUpdateDto log, int id) { GetClient(); LogDto updatedLog = null; HttpResponseMessage response = await client.PutAsJsonAsync($"api/Log/{id}", log); if (response.IsSuccessStatusCode) { updatedLog = await response.Content.ReadAsAsync <LogDto>(); } return(updatedLog); }
private async void ClickEdit(object sender, EventArgs e) { //Startuur string StartHour = StartTime.Time.Hours.ToString(); string StartMin = StartTime.Time.Minutes.ToString(); string StartT = $"{StartHour}:{StartMin}"; DateTime start = new DateTime(date.Year, date.Month, date.Day, int.Parse(StartHour), int.Parse(StartMin), 0); //Einduur string EndHour = EndTime.Time.Hours.ToString(); string EndMin = EndTime.Time.Minutes.ToString(); string EndT = $"{EndHour}:{EndMin}"; DateTime end = new DateTime(date.Year, date.Month, date.Day, int.Parse(EndHour), int.Parse(EndMin), 0); string value = ProjectList.SelectedItem.ToString(); int projectid = 0; //Zoekt id van project foreach (var project in projectsWithKey) { if (project.Value == value) { projectid = project.Key; } } //LOgs toevoegen na validatie uren en description if (CheckTimePicker() == true && CheckDescription() == true) { //Alle gegevens in een log object steken LogToUpdateDto log = new LogToUpdateDto() { ProjectID = projectid, StartTime = start, StopTime = end, Description = DescriptionEntry.Text }; LogDto logDto = await logServices.UpdateLogByIdAsync(log, logId); Application.Current.MainPage = new ProjectInfo(int.Parse(idPreviousProject)); } }