/// <summary> /// edits the specified appoint in the db /// </summary> /// <param name="appointment"></param> public void PutAppointment(APTDETAILS appointment) { using (db = new OptikItDbContext()) { var appointmentToEditQuery = from a in db.APTDETAILS where a.APD_STAMP == appointment.APD_STAMP select a; foreach (var a in appointmentToEditQuery) { a.APD_DATE = appointment.APD_DATE; a.APD_TIMEFROM = appointment.APD_TIMEFROM; a.APD_TIMETO = appointment.APD_TIMETO; a.APD_USER = appointment.APD_USER; a.APD_DESCRIPTION = appointment.APD_DESCRIPTION; a.APD_TYPE = appointment.APD_TYPE; a.APD_ROOM = appointment.APD_ROOM; a.APD_MOBILE = appointment.APD_MOBILE; a.APD_EMAIL = appointment.APD_EMAIL; } try { db.SaveChanges(); } catch (Exception) { } } }
/// <summary> /// Deletes specified custoemr from db /// </summary> /// <param name="customer"></param> public void DeleteCustomer(CUSTOMERS customer) { using (db = new OptikItDbContext()) { var removeQuery = from a in db.CUSTOMERS where a.CS_STAMP == customer.CS_STAMP select a; foreach (var a in removeQuery) { db.CUSTOMERS.Remove(a); } try { db.SaveChanges(); } catch (Exception) { } } }
/// <summary> /// cancels / deletes the specified appointment from db /// </summary> /// <param name="appointment"></param> public void DeleteAppointment(APTDETAILS appointment) { using (_db = new OptikItDbContext()) { var removeQuery = from a in _db.APTDETAILS where a.APD_STAMP == appointment.APD_STAMP select a; foreach (var a in removeQuery) { _db.APTDETAILS.Remove(a); } try { _db.SaveChanges(); } catch (Exception) { } } }
/// <summary> /// creates new specified customer in db /// </summary> /// <param name="customer"></param> public void PostCustomer(CUSTOMERS customer) { using (db = new OptikItDbContext()) { try { db.CUSTOMERS.Add(customer); db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } } }
/// <summary> /// post new appointment to the db /// </summary> /// <param name="appointment"></param> public void PostAppointment(APTDETAILS appointment) { using (db = new OptikItDbContext()) { try { db.APTDETAILS.Add(appointment); db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } } }
/// <summary> /// edits specified customer in db /// </summary> /// <param name="customer"></param> public void PutCustomer(CUSTOMERS customer) { using (db = new OptikItDbContext()) { var appointmentToEditQuery = from a in db.CUSTOMERS where a.CS_CPRNO == customer.CS_CPRNO select a; foreach (var a in appointmentToEditQuery) { a.CS_CPRNO = customer.CS_CPRNO; a.CS_FIRSTNAME = customer.CS_FIRSTNAME; a.CS_LASTNAME = customer.CS_LASTNAME; a.CS_ADRESS1 = customer.CS_ADRESS1; a.CS_PHONEMOBILE = customer.CS_PHONEMOBILE; a.CS_EMAIL = customer.CS_EMAIL; } try { db.SaveChanges(); } catch (Exception) { } } }