public IHttpActionResult GetEvents(string alias, string fromDate = null) { if (!paramParser.TryParseNullableDateTime(fromDate, out DateTime? fromDateValue)) { return(errorsFactory.CreateBadRequest(this, fromDate, nameof(fromDate))); } try { var events = divisionsService.GetEvents(alias, fromDateValue); if (events == null) { return(errorsFactory.CreateNotFound(this, $"Extracur division '{alias}' was not found" )); } return(Content(HttpStatusCode.OK, events)); } catch (NotSupportedException ex) { return(errorsFactory.CreateBadRequest(this, ex.Message)); } }
public IHttpActionResult GetGroups(string id) { if (!int.TryParse(id, out int idValue)) { return(errorsFactory.CreateBadRequest(this, id, nameof(id))); } var groups = programsService.GetGroups(idValue); if (groups == null) { return(errorsFactory.CreateNotFound(this, $"Study Program id={id} was not found" )); } return(Content(HttpStatusCode.OK, groups)); }
public IHttpActionResult IsBusy(string oid, string start, string end) { if (!Guid.TryParse(oid, out Guid oidValue)) { return(errorsFactory.CreateBadRequest(this, oid, nameof(oid))); } if (!parseDateTime(start, out DateTime startValue)) { return(errorsFactory.CreateBadRequest(this, start, nameof(start))); } if (!parseDateTime(end, out DateTime endValue)) { return(errorsFactory.CreateBadRequest(this, end, nameof(end))); } var contract = classroomsService.IsBusy(oidValue, startValue, endValue); if (contract == null) { return(errorsFactory.CreateNotFound(this, $"Classroom oid='{oid}' was not found" )); } return(Content(HttpStatusCode.OK, contract)); bool parseDateTime(string value, out DateTime result) => DateTime.TryParseExact(value, "yyyyMMddHHmm", null, DateTimeStyles.None, out result); }
public IHttpActionResult GetEvents(string id, TimeTableKindСode timetable = TimeTableKindСode.Unknown) { if (!int.TryParse(id, out int idValue)) { return(errorsFactory.CreateBadRequest(this, id, nameof(id))); } var events = groupsService.GetWeekEvents(idValue, timeTableKindCode: timetable); if (events == null) { return(errorsFactory.CreateNotFound(this, $"Student group id={id} was not found" )); } return(Content(HttpStatusCode.OK, events)); }
public IHttpActionResult GetEvents(string id, string showNextTerm = null) { if (!int.TryParse(id, out int idValue)) { return(errorsFactory.CreateBadRequest(this, id, nameof(id))); } if (!paramParser.TryParseNullableInt32(showNextTerm, out int?showNextTermValue)) { return(errorsFactory.CreateBadRequest(this, showNextTerm, nameof(showNextTerm))); } var events = educatorsService.GetEvents(idValue, showNextTermValue); if (events == null) { return(errorsFactory.CreateNotFound(this, $"Educator id={id} was not found" )); } return(Content(HttpStatusCode.OK, events)); }
public IHttpActionResult Get( string seating = null, string capacity = null, string equipment = null) { if (!paramParser.TryParseNullableSeating(seating, out Seating? seatingValue)) { return(errorsFactory.CreateBadRequest(this, seating, nameof(seating))); } if (!paramParser.TryParseNullableInt32(capacity, out int?minCapacityValue)) { return(errorsFactory.CreateBadRequest(this, capacity, nameof(capacity))); } var equipmentElements = GetEquipmentElements(equipment); var addresses = addressesService.Get(equipmentElements, seatingValue, minCapacityValue); return(Content(HttpStatusCode.OK, addresses)); }