Example #1
0
 public IActionResult OperAdd(int?idplan)
 {
     if (idplan != null)
     {
         OperAddVM p = new OperAddVM();
         p.idplan = idplan;
         return(View(p));
     }
     else
     {
         return(RedirectToAction("PlanHome", "Home"));
     }
 }
Example #2
0
        public async Task <IActionResult> OperAdd(OperAddVM oper)
        {
            if (ModelState.IsValid)
            {
                Plan pl = await db.Plans.FirstOrDefaultAsync(u => u.Id == oper.idplan);

                pl.SumPlOper += oper.Sum;
                db.Operations.Add(new Operation {
                    Name = oper.Name, NameAct = oper.NameAct, Coment = oper.Coment, Sum = oper.Sum, Plan = pl
                });
                await db.SaveChangesAsync();

                return(RedirectToAction("OperHome", "Home", new { idplan = oper.idplan }));
            }
            return(View(oper));
        }