Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            BiopsychosocialState biopsychosocialState = db.BiopsychosocialStates.Find(id);

            db.BiopsychosocialStates.Remove(biopsychosocialState);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "BPSId,SleepQuality,TrustInSelf,Stress")] BiopsychosocialState biopsychosocialState)
 {
     if (ModelState.IsValid)
     {
         db.Entry(biopsychosocialState).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(biopsychosocialState));
 }
Example #3
0
        public ActionResult Create([Bind(Include = "BPSId,SleepQuality,TrustInSelf,Stress")] BiopsychosocialState biopsychosocialState)
        {
            if (ModelState.IsValid)
            {
                db.BiopsychosocialStates.Add(biopsychosocialState);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(biopsychosocialState));
        }
Example #4
0
        // GET: BiopsychosocialStates/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BiopsychosocialState biopsychosocialState = db.BiopsychosocialStates.Find(id);

            if (biopsychosocialState == null)
            {
                return(HttpNotFound());
            }
            return(View(biopsychosocialState));
        }
        public ActionResult Create(SessionBPSViewModel sBPS)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (sBPS.session.SessionId > 0)
                    {
                        var currentSets = db.SessionSets.Where(s => s.SessionId == sBPS.session.SessionId);

                        foreach (SessionSet ss in currentSets)
                        {
                            db.SessionSets.Remove(ss);
                        }

                        foreach (SessionSet ss in sBPS.session.Sets)
                        {
                            db.SessionSets.Add(ss);
                        }

                        db.Entry(sBPS).State = EntityState.Modified;
                    }
                    else
                    {
                        Session ses = new Session();
                        BiopsychosocialState bps = new BiopsychosocialState();

                        ses.Commentary  = sBPS.session.Commentary;
                        ses.SessionDate = sBPS.session.SessionDate;
                        db.Sessions.Add(ses);
                        db.SaveChanges();

                        bps       = sBPS.bps;
                        bps.BPSId = ses.SessionId;

                        db.BiopsychosocialStates.Add(bps);
                        db.SaveChanges();
                    }
                    //return RedirectToAction("Index");
                    return(Json(new { Success = 1, sBPS.session.SessionId, ex = "" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Success = 0, ex = ex.Message.ToString() }));
            }

            //return View(sBPS);
            return(Json(new { Success = 0, ex = new Exception("Unable to save").Message.ToString() }));
        }