Beispiel #1
0
        public Owner Update(Owner ownerUpdate)
        {
            var addedOwner = _ctx.Update(ownerUpdate).Entity;

            _ctx.SaveChanges();
            return(addedOwner);
        }
Beispiel #2
0
        public Owner UpdateOwner(Owner owner)
        {
            var entityEntry = _ctx.Update(owner);

            _ctx.SaveChanges();
            return(entityEntry.Entity);
        }
Beispiel #3
0
        public Pet UpdatePet(Pet pet)
        {
            var entityEntry = _ctx.Update(pet);

            _ctx.SaveChanges();
            return(entityEntry.Entity);
        }
Beispiel #4
0
        public Owner UpdateOwner(Owner owner)
        {
            var ownerUpdated = _ctx.Update(owner).Entity;

            _ctx.SaveChanges();
            return(ownerUpdated);
        }
Beispiel #5
0
        public Pet Update(Pet petUpdate)
        {
            if (petUpdate.owner != null)
            {
                petUpdate.owner = _ctx.Owners.FirstOrDefault(o => o.id == petUpdate.owner.id);
            }
            var addedPet = _ctx.Update(petUpdate).Entity;

            _ctx.SaveChanges();
            return(petUpdate);
        }
 public Pet Update(Pet updatePet)
 {
     foreach (var pet in _ctx.Pets)
     {
         if (updatePet.Id == pet.Id)
         {
             // _ctx.Pets.Remove(pet);
             // _ctx.Pets.Update(updatePet.Id - 1, updatePet);
             var entityEntry = _ctx.Update(pet);
             _ctx.SaveChanges();
             return(entityEntry.Entity);
         }
     }
     return(updatePet);
 }
Beispiel #7
0
        public async Task <IActionResult> EditSopstvenik(int id, SopstvenikEditVM vm)
        {
            if (id != vm.Sopstvenik.Id)
            {
                return(NotFound());
            }

            //if (ModelState.IsValid)
            //{

            try
            {
                _context.Update(vm.Sopstvenik);
                await _context.SaveChangesAsync();

                IEnumerable <int>     listProdukt = vm.SelectedProducts;
                IQueryable <Junction> toBeRemoved = _context.Junction.Where(s => !listProdukt.Contains(s.ProduktID) && s.SopstvenikID == id);
                _context.Junction.RemoveRange(toBeRemoved);
                IEnumerable <int> existProdukts = _context.Junction.Where(s => listProdukt.Contains(s.ProduktID) && s.SopstvenikID == id).Select(s => s.ProduktID);
                IEnumerable <int> newProdukts   = listProdukt.Where(s => !existProdukts.Contains(s));
                foreach (int produktId in newProdukts)
                {
                    _context.Junction.Add(new Junction {
                        ProduktID = produktId, SopstvenikID = id
                    });
                }
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SopstvenikExists(vm.Sopstvenik.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction(nameof(IndexSopstvenik)));
            //}
            // return View(vm);
        }
Beispiel #8
0
 public void Update <T>(T entity) where T : class
 {
     _context.Update(entity);
 }