Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            MeebaInfo meebaInfo = db.MeebaInfoes.Find(id);

            db.MeebaInfoes.Remove(meebaInfo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "ID,itemName,category,pull,apptInt,workInt,socInt,evtInt,persInt,otherInt,innerInt,OuterInt")] MeebaInfo meebaInfo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(meebaInfo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(meebaInfo));
 }
Пример #3
0
        public ActionResult PostEvent([Bind(Include = "ID,itemName,category,pull")] MeebaInfo meeba)
        {
            switch (meeba.category)
            {
            case "Social":
                meeba.socInt++;
                break;

            case "Appointment":
                meeba.apptInt++;
                break;

            case "Work":
                meeba.workInt++;
                break;

            case "Events":
                meeba.evtInt++;
                break;

            case "Other":
                meeba.otherInt++;
                break;

            case "Personal":
                meeba.persInt++;
                break;
            }

            switch (meeba.pull)
            {
            case "Inner":
                meeba.innerInt++;
                meeba.OuterInt--;
                break;

            case "Outer":
                meeba.OuterInt++;
                meeba.innerInt--;
                break;
            }

            meeba.userID = User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                db.MeebaInfoes.Add(meeba);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(new JsonResult()
            {
                Data = JsonConvert.SerializeObject(meeba.ID), JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "ID,itemName,category,pull,apptInt,workInt,socInt,evtInt,persInt,otherInt,innerInt,OuterInt")] MeebaInfo meebaInfo)
        {
            if (ModelState.IsValid)
            {
                db.MeebaInfoes.Add(meebaInfo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(meebaInfo));
        }
Пример #5
0
        // GET: MeebaInfoes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MeebaInfo meebaInfo = db.MeebaInfoes.Find(id);

            if (meebaInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(meebaInfo));
        }
        public ActionResult DeleteConfirmed(int id, string category, string pull)
        {
            MeebaInfo meebaInfo = db.MeebaInfoes.Find(id);

            // Runs a switch statement with the category passed in
            // That will decrement the value of that category from the Meeba
            // If the object is holds the category
            switch (category)
            {
            case "Social":
                meebaInfo.socInt--;
                break;

            case "Appointment":
                meebaInfo.apptInt--;
                break;

            case "Work":
                meebaInfo.workInt--;
                break;

            case "Events":
                meebaInfo.evtInt--;
                break;

            case "Other":
                meebaInfo.otherInt--;
                break;

            case "Personal":
                meebaInfo.persInt--;
                break;
            }

            switch (pull)
            {
            case "Inner":
                meebaInfo.innerInt--;
                break;

            case "Outer":
                meebaInfo.OuterInt--;
                break;
            }

            db.MeebaInfoes.Remove(meebaInfo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // Passes the users input from the View back to the controller
        // To be saved into the database
        // However, if it is not a valid input
        // The user will be redirected to an error page
        public ActionResult PostEvent([Bind(Include = "ID,itemName,category,pull")] MeebaInfo meeba)
        {
            // Passes the category into the switch statement
            // If the category is matches a case, it will increment
            // That category in the database
            switch (meeba.category)
            {
            case "Social":
                meeba.socInt++;
                break;

            case "Appointment":
                meeba.apptInt++;
                break;

            case "Work":
                meeba.workInt++;
                break;

            case "Events":
                meeba.evtInt++;
                break;

            case "Other":
                meeba.otherInt++;
                break;

            case "Personal":
                meeba.persInt++;
                break;
            }
            //Gets a list of inputs for the user
            //Based on the currently logged in user

            var currentUser = User.Identity.GetUserId();
            var userMeeba   = from user in db.MeebaInfoes
                              where user.userID == currentUser
                              select user;

            // Applies the integer for inner and outer
            // Based on the integers in the database
            foreach (var outer in userMeeba)
            {
                userOuter += outer.OuterInt;
            }
            foreach (var inner in userMeeba)
            {
                userInner += inner.innerInt;
            }

            // Applies the integers to a ViewData value
            // To be accessed by the View
            ViewData["Outer"] = userOuter;
            ViewData["Inner"] = userInner;

            // Passes the pull into the switch statement
            // If the pull matches the case, increment
            // The pull, and decrement its opposite
            // Value, so long as that value is greater
            // Than 1
            switch (meeba.pull)
            {
            case "Outer":
                meeba.OuterInt++;
                if (userInner > 1)
                {
                    meeba.innerInt--;
                }
                break;

            case "Inner":
                meeba.innerInt++;
                if (userOuter > 1)
                {
                    meeba.OuterInt--;
                }
                break;
            }

            meeba.userID = User.Identity.GetUserId();

            // If the input is valid for the Model
            // Save the input to the database
            if (ModelState.IsValid)
            {
                db.MeebaInfoes.Add(meeba);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            // If the input is incorrect,
            // Redirect to the error page
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Error"));
            }

            return(new JsonResult()
            {
                Data = JsonConvert.SerializeObject(meeba.ID), JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }