Exemplo n.º 1
0
        public async Task <IActionResult> PlanRed(int?id)
        {
            Plan pl = await db.Plans.FirstAsync(p => p.Id == id);

            PlanRedVM plan = new PlanRedVM();

            plan.Name       = pl.Name;
            plan.Data       = pl.Data;
            plan.DataPeriod = pl.DataPeriod;
            plan.idplan     = id;
            return(View(plan));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PlanRed(PlanRedVM plan)
        {
            if (ModelState.IsValid)
            {
                Plan pl = await db.Plans.FirstAsync(p => p.Id == plan.idplan);

                pl.Name       = plan.Name;
                pl.Data       = plan.Data;
                pl.DataPeriod = plan.DataPeriod;
                db.Plans.Update(pl);
                await db.SaveChangesAsync();

                return(RedirectToAction("PlanHome", "Home"));
            }
            return(View(plan));
        }