Beispiel #1
0
        public ActionResult Create([Bind(Include = "KPM_ID,KPM_Event,KPM_FPercent,KPM_SPercent,KPY_ID")] kpi_Perfomance kpi_Perfomance)
        {
            if (ModelState.IsValid)
            {
                db.kpi_Perfomance.Add(kpi_Perfomance);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.KPY_ID = new SelectList(db.kpi_Year, "KPY_ID", "KPY_Name", kpi_Perfomance.KPY_ID);
            return(View(kpi_Perfomance));
        }
Beispiel #2
0
        public ActionResult Create(KPI model, string[] emails)
        {
            var user = User.Identity.Name.Split('@')[0];

            if (db.KPIs.Find(model.idKPI).Email != user)
            {
                return(HttpNotFound());
            }
            emails = emails ?? new string[] { user };
            if (ModelState.IsValid)
            {
                using (var scope = new TransactionScope())
                {
                    foreach (var email in emails)
                    {
                        db.KPIs.Add(new KPI
                        {
                            Email     = email,
                            idKPI     = model.idKPI,
                            MucTieu   = model.MucTieu,
                            TyTrong   = model.TyTrong,
                            ChiTieu   = model.ChiTieu,
                            DonViTinh = model.DonViTinh,
                            GhiChu    = model.GhiChu
                        });
                        LogInfo(model);
                    }
                    db.SaveChanges();
                    scope.Complete();
                    return(RedirectToAction("Details", new { id = -model.idKPI }));
                }
            }

            ViewBag.KPI   = db.KPIs.Find(model.idKPI);
            ViewBag.Names = db.KpiUsers.First().Names;
            return(View(model));
        }