Esempio n. 1
0
        public ActionResult Index([Bind(Include = "IdRaidValue,RaidDate,IDPlayer,IDAttendance,MinusAddition,PlusAddition,IDIsActive")] raiddates raiddates, int?id, DateTime?RTDate, string LogsHref)
        {
            var RDI = id ?? 0;

            if (ModelState.IsValid && raiddates.IDPlayer != "" && raiddates.IDPlayer != null)
            {
                db.Entry(raiddates).State = EntityState.Modified;
                db.SaveChanges();
            }
            var RTC = -1;

            if (id.HasValue)
            {
                RTC = db.raiddatetable.Where(t => t.idRaidDateTable == id).ToList().Count();
            }
            if (RTDate.HasValue)
            {
                RTC = db.raiddatetable.Where(t => t.RaidDate == RTDate).ToList().Count();
            }
            if (RTC == 0)
            {
                string          cnnString = "server=localhost;user id=root;password=Kageretsu;persistsecurityinfo=True;database=staticdb";
                MySqlConnection cnn       = new MySqlConnection(cnnString);
                MySqlCommand    cmd       = new MySqlCommand();
                cmd.Connection  = cnn;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = "NewRaidData";
                cmd.Parameters.Add(new MySqlParameter("InputDate", RTDate));
                //add any parameters the stored procedure might require
                cnn.Open();
                var result = cmd.ExecuteNonQuery();
                cnn.Close();
                RDI = db.raiddatetable.Where(t => t.RaidDate == RTDate).ToList().First().idRaidDateTable;
            }
            else
            {
                if (RTDate.HasValue)
                {
                    raiddatetable raiddatetable = new raiddatetable();
                    raiddatetable        = db.raiddatetable.Where(t => t.RaidDate == RTDate).First();
                    raiddatetable.LogRef = LogsHref;
                    db.SaveChanges();
                }
                if (raiddates.RaidDate.HasValue)
                {
                    raiddatetable raiddatetable = new raiddatetable();
                    raiddatetable        = db.raiddatetable.Where(t => t.idRaidDateTable == raiddates.RaidDate).First();
                    raiddatetable.LogRef = LogsHref;
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("Index", new { id = RDI }));
        }
Esempio n. 2
0
        public ActionResult Edit([Bind(Include = "IdRaidValue,RaidDate,IDPlayer,IDAttendance,MinusAddition,PlusAddition,IDIsActive")] raiddates raiddates, int?id)
        {
            raiddates raiddatesItem = db.raiddates.Where(r => r.IdRaidValue == id).First();

            ViewBag.IDAttendance = new SelectList(db.attendance_list, "ID_attendance", "ID_attendance", raiddatesItem.IDAttendance);
            if (id.HasValue)
            {
                var ModelDB   = db.raiddates;
                var ModelItem = ModelDB.Where(r => r.IdRaidValue == id).First();
                raiddates = ModelItem;
            }
            return(PartialView(raiddates));
        }
Esempio n. 3
0
        public ActionResult Edit(int?id)
        {
            raiddates raiddates = db.raiddates.Find(id);

            ViewBag.IDAttendance = new SelectList(db.attendance_list, "ID_attendance", "ID_attendance", raiddates.IDAttendance);
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (raiddates == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(raiddates));
        }