public ActionResult <Domain.Models.PhoneBook> CreateOrUpdatePhoneBook(Models.PhoneBook phoneBook) { try { var domainPhoneBook = _mapper.Map <Models.PhoneBook, Domain.Models.PhoneBook>(phoneBook); _phoneBookManager.CreateOrUpdatePhoneBook(domainPhoneBook); var result = _mapper.Map <Domain.Models.PhoneBook, Models.PhoneBook>(domainPhoneBook); return(Ok(domainPhoneBook)); } catch (Exception exception) { return(BadRequest(exception)); } }
public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here Models.PhoneBook phoneBookMember = database.PhoneBooks.SingleOrDefault(c => c.phone_id == id); database.PhoneBooks.Remove(phoneBookMember); database.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here Models.PhoneBook phoneBookMember = database.PhoneBooks.SingleOrDefault(c => c.phone_id == id); phoneBookMember.name = collection["name"]; phoneBookMember.number = collection["number"]; database.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here Models.PhoneBook phoneBookMember = new Models.PhoneBook(); phoneBookMember.name = collection["name"]; phoneBookMember.number = collection["number"]; database.PhoneBooks.Add(phoneBookMember); database.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public int ubaci(PhoneBookDT p) { PhoneBook.Models.PhoneBook novo = new Models.PhoneBook(); { novo.Ime = p.Ime; novo.Prezime = p.Prezime; novo.BrojTelefona = p.BrojTelefona; } try { db.PhoneBook.Add(novo); //db.PhoneBook.Add(new PhoneBook.Models.PhoneBook{Ime="pera",Prezime="Perkovic3",BrojTelefona=4444 }); db.SaveChanges(); return(1); } catch (Exception) { return(0); throw; } }
public async Task <Models.PhoneBook> SavePhoneBookAsync(Models.PhoneBook phoneBook) { if (phoneBook.Id > 0) { var result = dbContext.PhoneBooks.Update(phoneBook); await dbContext.SaveChangesAsync(); result.State = EntityState.Detached; return(result.Entity); } else { var result = dbContext.PhoneBooks.Add(phoneBook); await dbContext.SaveChangesAsync(); result.State = EntityState.Detached; return(result.Entity); } }
// GET: Home/Delete/5 public ActionResult Delete(int id) { Models.PhoneBook phoneBookMember = database.PhoneBooks.SingleOrDefault(c => c.phone_id == id); return(View()); }
public EntriesController(PhoneBookContext context) { _context = context; _phoneBook = new Models.PhoneBook(); }
public Task <Models.PhoneBook> Save(Models.PhoneBook phoneBook) { return(_repository.SavePhoneBookAsync(phoneBook)); }