Example #1
0
        public int izmeni(PhoneBookDT p)
        {
            if (ModelState.IsValid)
            {
                PhoneBook.Models.PhoneBook novo = db.PhoneBook.Find(p.Id);
                {
                    novo.Ime          = p.Ime;
                    novo.Prezime      = p.Prezime;
                    novo.BrojTelefona = p.BrojTelefona;
                    try
                    {
                        db.Entry(novo).State = EntityState.Modified;
                        db.SaveChanges();
                        return(1);
                    }
                    catch (Exception)
                    {
                        return(0);

                        throw;
                    }
                }
            }
            return(0);
        }
Example #2
0
 public int obrisi(int id)
 {
     PhoneBook.Models.PhoneBook zaBris = db.PhoneBook.Find(id);
     if (zaBris == null)
     {
         return(-1);
     }
     try
     {
         db.PhoneBook.Remove(zaBris);
         db.SaveChanges();
     }
     catch (Exception)
     {
         return(-1);
     }
     return(1);
 }