public static DeviceAccessRestriction Populate(int accessRestrictionId) { try { marcdissertation_dbEntities ctxt = new marcdissertation_dbEntities(); DeviceAccessRestriction dar = (from x in ctxt.DeviceAccessRestrictions where x.AccessRestrictionId == accessRestrictionId select x).First(); dar.context = ctxt; return(dar); } catch (Exception ex) { throw ex; } }
public static DeviceAccessRestriction CreateDeviceAccessRestriction(int deviceId, DayOfWeek dow, TimeSpan startTime, TimeSpan endTime) { DeviceAccessRestriction dar = new DeviceAccessRestriction(); dar.DeviceId = deviceId; dar.Day = (int) dow; dar.StartTime = startTime; dar.EndTime = endTime; dar.context = new marcdissertation_dbEntities(); dar = dar.context.DeviceAccessRestrictions.Add(dar); errors = dar.context.GetValidationErrors(); try { dar.context.SaveChanges(); } catch { throw App.ExceptionFormatter(errors); } return dar; }
public static DeviceAccessRestriction CreateDeviceAccessRestriction(int deviceId, DayOfWeek dow, TimeSpan startTime, TimeSpan endTime) { DeviceAccessRestriction dar = new DeviceAccessRestriction(); dar.DeviceId = deviceId; dar.Day = (int)dow; dar.StartTime = startTime; dar.EndTime = endTime; dar.context = new marcdissertation_dbEntities(); dar = dar.context.DeviceAccessRestrictions.Add(dar); errors = dar.context.GetValidationErrors(); try { dar.context.SaveChanges(); } catch { throw App.ExceptionFormatter(errors); } return(dar); }