static void ShowFRCEvent(FRCEvent item) { Console.WriteLine( $"Id: {item.Id} - Uuid: {item.Uuid}" + $" - EventKey: {item.EventKey}" + $" - Name: {item.Name}" + $" - Location: {item.Location}"); }
public void PutFRCEvent(string uuid, FRCEvent item) { item.Uuid = uuid; if (!repository.Update(item)) { throw new HttpResponseException(HttpStatusCode.NotFound); } }
static async Task <Uri> CreateFRCEventAsync(FRCEvent item) { HttpResponseMessage response = await client.PostAsJsonAsync("api/FRCEvents", item); response.EnsureSuccessStatusCode(); // return URI of the created resource. return(response.Headers.Location); }
public HttpResponseMessage PostFRCEvent(FRCEvent item) { item.Id = null; // clear for autoincrement item = repository.Add(item); var response = Request.CreateResponse(HttpStatusCode.Created, item); string uri = Url.Link("DefaultApi", new { uuid = item.Uuid }); response.Headers.Location = new Uri(uri); return(response); }
public FRCEvent GetFRCEvent(string uuid) { FRCEvent item = repository.GetByUuid(uuid); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(item); }
public Task <int> SaveFRCEventAsync(FRCEvent item) { // note: the caller must let this resolve before item.Id is first // available, using either "await" or "int x = ...().Result;" if (item.Uuid == null) { item.Uuid = Guid.NewGuid().ToString(); } return(_database.InsertOrReplaceAsync(item)); }
static async Task <FRCEvent> GetFRCEventAsync(string path) { FRCEvent item = null; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { item = await response.Content.ReadAsAsync <FRCEvent>(); } return(item); }
static async Task <FRCEvent> UpdateFRCEventAsync(FRCEvent item) { HttpResponseMessage response = await client.PutAsJsonAsync( $"api/FRCEvents?uuid={item.Uuid}", item); response.EnsureSuccessStatusCode(); // Deserialize the updated FRCEvent from the response body. item = await response.Content.ReadAsAsync <FRCEvent>(); return(item); }
public NewFRCEventPage() { InitializeComponent(); FRCEvent = new FRCEvent { Name = "FRC Event name", Location = "FRC Event location" }; BindingContext = this; }
public FRCEventDetailPage() { InitializeComponent(); var item = new FRCEvent { Name = "Event 1 Name", Location = "Event 1 Location" }; viewModel = new FRCEventDetailViewModel(item); BindingContext = viewModel; }
void OnItemSelected(object sender, SelectedItemChangedEventArgs args) { FRCEvent item = (FRCEvent)args.SelectedItem; if (item == null) { return; } App.currFRCEventKey = item.EventKey; App.currFRCEventName = item.Name; App.highestMatchNumber = 0; this.Title = item.Name; if (_preparing) { return; } Navigation.PopAsync(); }
public FRCEventDetailViewModel(FRCEvent item = null) { Title = item?.Name; FRCEvent = item; }
private void doAddNewEvent() { string eventName = Entry_EventName.Text; string eventKey = Entry_EventKey.Text; string eventLocation = Entry_EventLocation.Text; string startDate = Start_DatePicker.Date.ToString("yyyy-MM-dd"); string endDate = End_DatePicker.Date.ToString("yyyy-MM-dd"); if (Start_DatePicker.Date > End_DatePicker.Date) { Label_ErrorMessage.Text = "Invalid end or start date"; Label_ErrorMessage2.Text = ""; return; } if (string.IsNullOrEmpty(eventName) || string.IsNullOrEmpty(eventKey) || string.IsNullOrEmpty(eventLocation)) { Label_ErrorMessage.Text = "Please fill out all fields."; Label_ErrorMessage2.Text = ""; return; } //add new event - does it already exist? //TODO: new events are not added to the database, so the program cannot compare event keys //TODO: also doesn't work for events in the database FRCEvent oldEvent = null; try { oldEvent = App.Database.GetEventAsync(eventKey); } catch (Exception) { //do nothing } if (oldEvent != null && oldEvent.Id != null) { Label_ErrorMessage.Text = $"Event {eventName} already exists."; Label_ErrorMessage2.Text = ""; return; } FRCEvent newEvent = new FRCEvent(); newEvent.EventKey = eventKey; newEvent.Name = eventName; newEvent.Location = eventLocation; newEvent.StartDate = startDate; newEvent.EndDate = endDate; newEvent.Changed = 1; App.Database.SaveFRCEventAsync(newEvent); Entry_EventName.Text = ""; Entry_EventKey.Text = ""; Entry_EventLocation.Text = ""; Label_ErrorMessage.Text = $"Added new event {Entry_EventName.Text}."; Label_ErrorMessage2.Text = $"Please exit to main page or add another event."; }