Exemplo n.º 1
0
        public ActionResult AddorEdit(Pomiar p2)
        {
            if (ModelState.IsValid)
            {
                context.Pomiars.Add(p2);
                context.SaveChanges();

                return(RedirectToAction("Details", "Pomiar", new { id = p2.PomiarId }));
            }

            return(View(p2));
        }
Exemplo n.º 2
0
        public ActionResult Delete(int id)
        {
            var data  = context.Pomiars.FirstOrDefault(x => x.PomiarId == id);
            var items = context.Items.Where(x => x.PomiarId == id).ToList();

            if (data != null)
            {
                context.Items.RemoveRange(items);
                context.Pomiars.Remove(data);
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }