public DBAbsence(string dbID, string start, string end, string reason) { var id = Convert.ToInt32(dbID); var startDate = Convert.ToDateTime(start); var endDate = Convert.ToDateTime(end); var absence = new DBAbsence(id, startDate, endDate, reason); this.Id = id; this.Start = absence.Start; this.End = absence.End; this.Reason = reason; }
public void UpdateAbscence(DBAbsence absence) { if (GetAbsenceById(absence.Id) == null) { throw new AbsenceNotFoundException(); } var absenceDB = GetAbsenceDB(); using (var connection = new SqliteConnection(absenceDB.ConnectionString)) { connection.Open(); var updateCmd = connection.CreateCommand(); updateCmd.CommandText = $"UPDATE absence SET Start = '{absence.Start}', End = '{absence.End }', Reason = '{absence.Reason}' WHERE Id = {absence.Id}"; } }
public async Task <IActionResult> PutAbsence(int id, DBAbsence absence) { if (id != absence.Id) { return(BadRequest()); } try { _absenceManager.UpdateAbscence(absence); } catch (AbsenceNotFoundException) { return(NotFound()); } return(NoContent()); }
public void UpdateAbscence(DBAbsence absence) { _absenceRepo.UpdateAbscence(absence); }