public ActionResult Delete(int?id) { string user = (string)Session["user"]; ViewBag.user = user; try { Entry e = new Models.Entry(); if (ModelState.IsValid) { if (id == null) { return(RedirectToAction("Index")); } e = db.Entries.Find(id); if (e == null) { return(HttpNotFound()); } db.Entries.Remove(e); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(e)); } catch { return(View()); } }
private async void CreateEntry() { Models.Entry entry1 = new Models.Entry(ImageSource = ImageSource, Caption = Caption, Address = Address, Species = Species); JournalViewModel.entries.Add(entry1); await App.Current.MainPage.Navigation.PopAsync(); }
public async Task <bool> SaveEntry(Models.Entry entry) { var result = false; await Task.Run(() => { result = true; }); return(result); }
public EditEntryViewModel(string listId, string entryId, string entryImageId) { this.UseLocation = true; this.ListId = listId; this.EntryId = entryId; if (this.entry == null) this.entry = new Models.Entry(); if (this.entryImage == null) this.entryImage = new Models.EntryImage(); if (string.IsNullOrEmpty(entryId)) { //Load the nearest place name, if possible var geo = this.GetService<Interfaces.IGeolocator>(); if (geo.CurrentPosition != null) { geo.LookupNearbyPlaces((nearestPlaceName) => { if (!string.IsNullOrEmpty(nearestPlaceName) && string.IsNullOrEmpty(this.entry.Store)) { this.entry.Store = nearestPlaceName; RaisePropertyChanged("Entry"); } }); } } }
protected Models.Entry ParseEntry(XmlNode xml_node) { Models.Entry parsed_entry = new Models.Entry(); parsed_entry.ID = Convert.ToInt32(xml_node.Attributes["ID"].Value); parsed_entry.Name = xml_node.Attributes["Name"].Value; parsed_entry.OddsDecimal = Convert.ToSingle(xml_node.Attributes["OddsDecimal"].Value); return(parsed_entry); }
public async Task AddNewEntry() { var entry = new Models.Entry(); int affected = await EntriesStore.SaveItemAsync(entry); if (affected > 0) { Entries.Add(entry); } }
public async Task <IActionResult> AddNewEntry([FromBody] Models.Entry entry, [FromServices] ApplicationDbContext db) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //db.Entries.Add(entry); //await db.SaveChangesAsync(); return(Created("", null)); }
public int SaveItem(Models.Entry item) { lock (locker) { if (item.ID != 0) { database.Update(item); return(item.ID); } else { return(database.Insert(item)); } } }
public ActionResult <Models.Entry> CreateOrUpdateEntry(Models.Entry entry) { try { var domainEntry = _mapper.Map <Models.Entry, Domain.Models.Entry>(entry); _entryManager.CreateOrUpdateEntry(domainEntry); var result = _mapper.Map <Domain.Models.Entry, Models.Entry>(domainEntry); return(Ok(result)); } catch (Exception exception) { return(BadRequest(exception)); } }
public async Task <IActionResult> UpdateEntry([FromBody] Models.Entry entry, [FromServices] ApplicationDbContext db) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var existingEntry = await db.Entries.SingleOrDefaultAsync(i => i.Id == entry.Id); if (existingEntry == null) { return(NotFound("Entry not found")); } return(NoContent()); }
public ActionResult Request() { Session["Request"] = null; Models.Country c = new Models.Country(); ViewBag.allcountry = c.GetallCountry(); Models.Entry e = new Models.Entry(); ViewBag.allentry = e.GetallEntry(); Models.Process_Time pt = new Models.Process_Time(); ViewBag.allprocess = pt.GetallProcess_Time(); if (Session["Nationality"] != null) { Models.Request r = new Models.Request(); r.Country_ID = Convert.ToInt32(Session["Nationality"]); return(View(r)); } return(View()); }
async Task DeleteEntry(Models.Entry entry) { try { await EntriesStore.DeleteItemAsync(entry); Entries.Remove(entry); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void SaveClicked(object sender, EventArgs e) { Models.Entry item = new Models.Entry() { Amount = Amount, Date = Date.ToString("yyyy/MM/dd"), Mean = MeanPicker.Items[MeanIndex], Note = Note, Reason = ReasonPicker.Items[ReasonIndex], Type = "Income" }; App.Database.SaveItem(item); PopupNavigation.PopAsync(); _main.LoadData(); }
public void LoadEntry() { if (string.IsNullOrEmpty(this.EntryId)) { return; } this.IsLoading = true; App.Azure.GetTable <Models.Entry>().LookupAsync(this.EntryId).ContinueWith((t) => { var ex = t.Exception; if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion) { this.entry = t.Result; RaisePropertyChanged("Entry"); App.Azure.GetTable <Models.EntryImage>().Where(ei => ei.ImageGuid == this.entry.ImageGuid).ToListAsync().ContinueWith((t2) => { var ex2 = t2.Exception; if (t2.Status == System.Threading.Tasks.TaskStatus.RanToCompletion && t2.Result.Count > 0) { this.entryImage = t2.Result[0]; RaisePropertyChanged("EntryImage"); RaisePropertyChanged("HasImage"); } }); } this.IsLoading = false; }); if (this.entry == null) { this.entry = new Models.Entry(); } if (this.entryImage == null) { this.entryImage = new Models.EntryImage(); } }
/// <summary> /// Runs in a background thread, checks for new Query and runs current one /// </summary> private async Task DelayedQueryForKeyboardTypingSearches(Models.Entry entry) { try { Interlocked.Exchange(ref throttleCts, new CancellationTokenSource()).Cancel(); await Task.Delay(TimeSpan.FromMilliseconds(1500), throttleCts.Token) .ContinueWith( async task => await SaveEntryCommand(entry), CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext() ); } catch { //Ignore any Threading errors } }
async Task SaveEntryCommand(Models.Entry entry) { if (entry == null) { return; } try { await EntriesStore.SaveItemAsync(entry); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private double GenerateTaskHours(Models.Entry entry, int iterator) { double hours = 0; Entry end = new Entry(); if (entries.Count() - 1 <= iterator) { end.DateCompleted = DateTime.Now; } else { end = entries[iterator + 1]; } TimeSpan diff = end.DateCompleted.Subtract(entry.DateCompleted); hours = Math.Round(diff.TotalHours, MidpointRounding.AwayFromZero); totalHours += hours; return(Math.Round(hours, MidpointRounding.AwayFromZero)); }
public ActionResult Request(Models.Request r) { clients = 0; if (ModelState.IsValid) { Session["Request"] = r; clients = r.Travelers; r.Addby = "Client"; r.addrequest(); Session["RRequest"] = r.R_ID; return(RedirectToAction("Client")); } else { Models.Country c = new Models.Country(); ViewBag.allcountry = c.GetallCountry(); Models.Entry e = new Models.Entry(); ViewBag.allentry = e.GetallEntry(); Models.Process_Time pt = new Models.Process_Time(); ViewBag.allprocess = pt.GetallProcess_Time(); return(View(r)); } }
public void SaveClicked(object sender, EventArgs e) { //Makes the expense negative if (amount > 0) { amount *= -1; } Models.Entry item = new Models.Entry() { Amount = Amount, Date = Date.ToString("yyyy/MM/dd"), Note = Note, Mean = "", Reason = Reason, Type = "Expense" }; App.Database.SaveItem(item); PopupNavigation.PopAsync(); _main.LoadData(); }
public void Edit(Models.Entry entry) { RequestNavigate <EditEntryViewModel>(new { listId = this.WishList.Id, entryId = entry.Id }); }
public void SaveClicked(object sender, EventArgs e) { //Makes the expense negative if (amount > 0) amount *= -1; Models.Entry item = new Models.Entry() { Amount = Amount, Date = Date.ToString("yyyy/MM//dd"), Note = Note, Mean="", Reason = Reason, Type = "Expense" }; App.Database.SaveItem(item); PopupNavigation.PopAsync(); _main.LoadData(); }
public void LoadEntry() { this.IsLoading = true; App.Azure.GetTable<Models.Entry>().LookupAsync(this.EntryId).ContinueWith((t) => { var ex = t.Exception; if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion) { this.entry = t.Result; RaisePropertyChanged("Entry"); if (!string.IsNullOrEmpty(this.entry.ImageGuid)) { App.Azure.GetTable<Models.EntryImage>().Where(ei => ei.ImageGuid == this.entry.ImageGuid).ToListAsync().ContinueWith((t2) => { var ex2 = t2.Exception; if (t2.Status == System.Threading.Tasks.TaskStatus.RanToCompletion && t2.Result.Count > 0) { this.entryImage = t2.Result[0]; RaisePropertyChanged("EntryImage"); RaisePropertyChanged("HasImage"); } this.IsLoading = false; }); } else this.IsLoading = false; } else { this.IsLoading = false; this.ReportError("Could not load Item!"); } }); }
public void SaveClicked(object sender, EventArgs e) { Models.Entry item = new Models.Entry() { Amount = Amount, Date = Date.ToString("yyyy/MM//dd"), Mean = MeanPicker.Items[MeanIndex], Note = Note, Reason = ReasonPicker.Items[ReasonIndex], Type = "Income" }; App.Database.SaveItem(item); PopupNavigation.PopAsync(); _main.LoadData(); }