コード例 #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 }));
        }
コード例 #2
0
        public ActionResult Index(int?id, DateTime?RTDate)
        {
            var RDI = id ?? 0;

            var modelDB     = db.raiddates.Where(rd => rd.RaidDate == RDI).Include(r => r.attendance_list);
            var ModelDBList = modelDB.ToList();
            var ModelItem   = new raiddatetable();

            if (ModelDBList.Count() > 0)
            {
                ModelItem = db.raiddatetable.Where(r => r.idRaidDateTable == RDI).First();
            }

            ViewBag.CanKarma  = true;
            ViewBag.Attenlist = db.attendance_list;
            ViewBag.RTdate    = ModelItem.RaidDate;
            ViewBag.LogsHref  = ModelItem.LogRef;
            return(View(ModelDBList));
        }