public async Task RemoveTelephoneNote(TelephoneNote telephoneNote) { using (var db = new ApplicationContext()) { db.TelephoneNotes.Remove(db.TelephoneNotes.Find(telephoneNote.Id)); await db.SaveChangesAsync(); } }
public async Task AddTelephoneNote(TelephoneNote telephoneNote) { using (var db = new ApplicationContext()) { db.TelephoneNotes.Add(telephoneNote); await db.SaveChangesAsync(); } }
public string UpdDict(string name, string phone) { var note = new TelephoneNote(name, phone); telephoneRepository.UpdateTelephoneNote(note).GetAwaiter(); return("OK"); }
public void Update([FromBody] TelephoneNote item) { TelephoneNote newContact = Get(item.Name); newContact.Phone = item.Phone; string json = JsonConvert.SerializeObject(Contacts); File.WriteAllText(file, json); }
public string DelDict(string name) { var note = new TelephoneNote() { Name = name }; telephoneRepository.RemoveTelephoneNote(note).GetAwaiter(); return("OK"); }
public TelephoneNote Add([FromBody] TelephoneNote item) { Contacts.Add(new TelephoneNote { Name = item.Name, Phone = item.Phone }); string json = JsonConvert.SerializeObject(Contacts); File.WriteAllText(file, json); return(item); }
public async Task UpdateTelephoneNote(TelephoneNote telephoneNote) { using (var db = new ApplicationContext()) { var updatedNote = db.TelephoneNotes.FirstOrDefault(x => x.Id == telephoneNote.Id); updatedNote.Name = telephoneNote.Name; updatedNote.Phone = telephoneNote.Phone; await db.SaveChangesAsync(); } }
public async Task <ActionResult> Delete(TelephoneNote telephoneNote) { try { await repository.RemoveTelephoneNote(telephoneNote); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <ActionResult> Update(TelephoneNote telephoneNote) { try { await telephoneRepository.UpdateTelephoneNote(telephoneNote); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <ActionResult> Create(TelephoneNote telephoneNote) { try { await telephoneRepository.AddTelephoneNote(telephoneNote); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task RemoveTelephoneNote(TelephoneNote telephoneNote) { List <TelephoneNote> noteList = await GetTelephoneNotes(); noteList.RemoveAll(x => x.Id == telephoneNote.Id); using (var fs = new FileStream(path, FileMode.Truncate)) { await JsonSerializer.SerializeAsync(fs, noteList); fs.Close(); } }
public async Task <ActionResult> Delete(TelephoneNote telephoneNote) { try { telephoneNote = (await telephoneRepository.GetTelephoneNotes()).FindLast(x => x.Name == telephoneNote.Name); await telephoneRepository.RemoveTelephoneNote(telephoneNote); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
private void Delete_Click(object sender, EventArgs e) { try { var telephoneNote = new TelephoneNote() { Namek__BackingField = this.name.Text, Phonek__BackingField = this.number.Text }; this.client.Delete(telephoneNote); Get_Click(sender, e); } catch (Exception exp) { MessageBox.Show("Fill required fields"); } }
public async Task AddTelephoneNote(TelephoneNote telephoneNote) { List <TelephoneNote> noteList; try { noteList = await GetTelephoneNotes(); telephoneNote.Id = noteList.Max(x => x.Id) + 1; } catch { noteList = new List <TelephoneNote>(); telephoneNote.Id = 1; } noteList.Add(telephoneNote); using (var fs = new FileStream(path, FileMode.OpenOrCreate)) { await JsonSerializer.SerializeAsync(fs, noteList); fs.Close(); } }
public async Task UpdateTelephoneNote(TelephoneNote telephoneNote) { await RemoveTelephoneNote(telephoneNote); await AddTelephoneNote(telephoneNote); }
public async Task RemoveTelephoneNote(TelephoneNote telephoneNote) { await _telephoneManager.RemoveTelephoneNote(telephoneNote); }
public async Task AddTelephoneNote(TelephoneNote telephoneNote) { await _telephoneManager.AddTelephoneNote(telephoneNote); }
public void Update(TelephoneNote telephoneNote) { telephoneRepository.UpdateTelephoneNote(telephoneNote); }
public async Task UpdateTelephoneNote(TelephoneNote telephoneNote) { await _telephoneManager.UpdateTelephoneNote(telephoneNote); }
// PUT api/values/5 public void Put(int id, [FromBody] TelephoneNote value) { }
// POST api/values public void Post([FromBody] TelephoneNote value) { }
public void Delete([FromBody] TelephoneNote telephoneNote) { telephoneNote = (telephoneRepository.GetTelephoneNotes().GetAwaiter().GetResult()).FindLast(x => x.Name == telephoneNote.Name); telephoneRepository.RemoveTelephoneNote(telephoneNote); }
public void Update([FromBody] TelephoneNote telephoneNote) { telephoneRepository.UpdateTelephoneNote(telephoneNote); }
public void Delete(TelephoneNote telephoneNote) { telephoneRepository.RemoveTelephoneNote(telephoneNote).GetAwaiter().GetResult(); }
public void Create([FromBody] TelephoneNote telephoneNote) { var x = Request; telephoneRepository.AddTelephoneNote(telephoneNote); }
public void Add(TelephoneNote telephoneNote) { telephoneRepository.AddTelephoneNote(telephoneNote).GetAwaiter().GetResult(); }