public bool Create([FromBody] SchoolContacts model) { try { _context.SchoolContacts.Add(model); return(_context.SaveChanges() == 1 ? true : false); } catch (Exception ex) { var error = ex.InnerException; return(false); } }
public bool Delete(int id) { SchoolContacts db = _context.SchoolContacts.Where(c => c.ID == id).FirstOrDefault(); try { _context.SchoolContacts.Remove(db); return(_context.SaveChanges() == 1 ? true : false); } catch (Exception ex) { var error = ex.InnerException; return(true); } }
public bool Edit([FromBody] SchoolContectUpdate model) { SchoolContacts db = _context.SchoolContacts.Where(c => c.ID == model.ID).FirstOrDefault(); try { if (db.ID == model.ID) { Mapper.Map(model, db); _context.SchoolContacts.Update(db); var result = _context.SaveChanges(); return(true); } return(false); } catch (Exception ex) { var error = ex.InnerException; return(false); } }