Ejemplo n.º 1
0
        public void Delete([FromRoute] int id)
        {
            var osoba = _personContext.People.FirstOrDefault(p => p.PersonId == id);

            _personContext.Remove(osoba);
            _personContext.SaveChanges();
        }
Ejemplo n.º 2
0
        public void DeletePerson(int id)
        {
            var personToDelete = GetPersonById(id);

            _context.Remove(personToDelete);
            _context.SaveChanges();
        }
Ejemplo n.º 3
0
 public IActionResult Delete(Person model)
 {
     //var personToDelete = context.Persons.Find(model.PersonId);
     //context.Persons.Remove(personToDelete);
     context.Remove(model);
     context.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public IEnumerable <Person> Delete(int id)
        {
            var p = personContext.Person.Where(person => person.Id == id).FirstOrDefault();

            if (p != null)
            {
                personContext.Remove(p);
                personContext.SaveChanges();
            }
            return(personContext.Person.ToArray());
        }
        public bool Delete(int id)
        {
            /*var ordersToRemove = _ctx.Orders.Where(o => o.Address.Id == id);
             * _ctx.RemoveRange(ordersToRemove);*/
            var custRemoved = _ctx.Remove(new Address {
                Id = id
            }).Entity;

            _ctx.SaveChanges();
            return(true); //custRemoved;
        }
Ejemplo n.º 6
0
 public void DeletePerson(Person person)
 {
     try
     {
         PersonDb.Remove(person);
         PersonDb.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        public bool Delete(int id)
        {
            /*var ordersToRemove = _ctx.Orders.Where(o => o.Person.Id == id);
             * _ctx.RemoveRange(ordersToRemove);*/
            var per = _ctx.People.FirstOrDefault(x => x.Id == id);

            if (per == null)
            {
                return(false);
            }
            var custRemoved = _ctx.Remove(per).Entity;

            _ctx.SaveChanges();
            return(true); //custRemoved;
        }
Ejemplo n.º 8
0
        public bool Delete(int id)
        {
            /*var ordersToRemove = _ctx.Orders.Where(o => o.Event.Id == id);
             * _ctx.RemoveRange(ordersToRemove);*/
            var evt = _ctx.Events.FirstOrDefault(x => x.Id == id);

            if (evt == null)
            {
                return(false);
            }

            //var custRemoved = _ctx.Remove(new coreevent.Event {Id = id}).Entity;
            var custRemoved = _ctx.Remove(evt).Entity;

            _ctx.SaveChanges();
            return(true); //custRemoved;
        }
Ejemplo n.º 9
0
            private static void Remove01(PersonContext ctx)
            {
                Person  person  = ctx.People.FirstOrDefault();
                JobData jobData = new JobData
                {
                    JobTitle = "Developer"
                };

                //person.JobData = jobData;
                Console.WriteLine("Person:" + ctx.Entry(person).State);
                Console.WriteLine("JobData:" + ctx.Entry(jobData).State);
                Console.WriteLine("ok");

                ctx.Remove(person);
                Console.WriteLine("Person:" + ctx.Entry(person).State);
                Console.WriteLine("JobData:" + ctx.Entry(jobData).State);
                Console.WriteLine("ok");
                ctx.SaveChanges();
                Console.WriteLine("Person:" + ctx.Entry(person).State);
                Console.WriteLine("JobData:" + ctx.Entry(jobData).State);
                Console.WriteLine("ok");
                Console.ReadLine();
            }
Ejemplo n.º 10
0
 public void RemovePerson(Person person)
 {
     _context.Remove(person);
     _context.SaveChanges();
 }
 public IActionResult RemovePerson([FromRoute] int id)
 {
     _personContext.Remove(_personContext.Persons.Find(id));
     _personContext.SaveChanges();
     return(NoContent());
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Delete person by Id
 /// </summary>
 /// <param name="Id">Unique identifier of person</param>
 public void Remove(Person person)
 {
     _PersonContext.Remove(person);
 }