Exemplo n.º 1
0
    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;
    }
Exemplo n.º 2
0
        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}";
            }
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
 public void UpdateAbscence(DBAbsence absence)
 {
     _absenceRepo.UpdateAbscence(absence);
 }