Esempio n. 1
0
        public ActionResult Edit(Ingredient i)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                using (var db = new Nu34lifeEntities())
                {
                    Ingredient ing = db.Ingredients.Find(i.Id);
                    ing.Name          = i.Name;
                    ing.Description   = i.Description;
                    ing.Protein       = i.Protein;
                    ing.Carbohydrates = i.Carbohydrates;
                    ing.Cholesterol   = i.Cholesterol;
                    ing.Fat           = i.Fat;
                    ing.Potasium      = i.Potasium;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 2
0
 public ActionResult ListaState()
 {
     using (var db = new Nu34lifeEntities())
     {
         return(PartialView(db.States.ToList()));
     }
 }
Esempio n. 3
0
 public ActionResult ListaNutritionist()
 {
     using (var db = new Nu34lifeEntities())
     {
         return(PartialView(db.Nutritionists.ToList()));
     }
 }
Esempio n. 4
0
 public ActionResult List_Instructions()
 {
     using (var db = new Nu34lifeEntities())
     {
         return(PartialView(db.Instructions.ToList()));
     }
 }
        public ActionResult Edit(Nutritionist n)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                using (var db = new Nu34lifeEntities())
                {
                    Nutritionist nu = db.Nutritionists.Find(n.Id);
                    nu.Name     = n.Name;
                    nu.LastName = n.LastName;
                    nu.Password = n.Password;
                    nu.Email    = n.Email;
                    nu.Birthday = n.Birthday;
                    nu.Validate = n.Validate;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 6
0
        public ActionResult Edit(State s)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                using (var db = new Nu34lifeEntities())
                {
                    State st = db.States.Find(s.Id);
                    st.Nutritionist_Id = s.Nutritionist_Id;
                    st.Patient_Id      = s.Patient_Id;
                    st.Description     = s.Description;
                    st.Weighr          = s.Weighr;
                    st.Height          = s.Height;
                    st.Glucose         = s.Glucose;
                    st.Affiliate       = s.Affiliate;
                    st.Generated_day   = s.Generated_day;
                    st.Expiration      = s.Expiration;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 7
0
        public ActionResult Edit(Membership m)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                using (var db = new Nu34lifeEntities())
                {
                    Membership me = db.Memberships.Find(m.Id);
                    me.Name        = m.Name;
                    me.Description = m.Description;
                    me.Duration    = m.Duration;
                    me.Amount      = m.Amount;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 8
0
        public ActionResult Edit(Allergy d)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                using (var db = new Nu34lifeEntities())
                {
                    Allergy all = db.Allergies.Find(d);
                    all.Description   = d.Description;
                    all.Ingredient_Id = d.Ingredient_Id;
                    all.Patient_Id    = d.Patient_Id;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 9
0
        public ActionResult Create()
        {
            var db = new Nu34lifeEntities();

            ViewBag.nutritionist = nutritionistService.Listar();
            return(View());
        }
Esempio n. 10
0
        public bool Insertar(Allergy a)
        {
            var db = new Nu34lifeEntities();

            db.Allergies.Add(a);
            db.SaveChanges();
            return(true);
        }
Esempio n. 11
0
 public ActionResult Details(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         Ingredient i = db.Ingredients.Find(id);
         return(View(i));
     }
 }
Esempio n. 12
0
 public ActionResult Details(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         Drug i = db.Drugs.Find(id);
         return(View(i));
     }
 }
Esempio n. 13
0
 public ActionResult Details(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         State s = db.States.Find(id);
         return(View(s));
     }
 }
Esempio n. 14
0
 public ActionResult Details(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         Nutritionist n = db.Nutritionists.Find(id);
         return(View(n));
     }
 }
Esempio n. 15
0
 public ActionResult Details(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         Allergy i = db.Allergies.Find(id);
         return(View(i));
     }
 }
Esempio n. 16
0
 public ActionResult Details(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         Membership i = db.Memberships.Find(id);
         return(View(i));
     }
 }
Esempio n. 17
0
        public bool Insertar(Recipe a)
        {
            var db = new Nu34lifeEntities();

            db.Recipes.Add(a);
            db.SaveChanges();
            return(true);
        }
Esempio n. 18
0
        public bool Insertar(Instruction a)
        {
            var db = new Nu34lifeEntities();

            db.Instructions.Add(a);
            db.SaveChanges();
            return(true);
        }
Esempio n. 19
0
        public bool Insertar(Nutritionist a)
        {
            var db = new Nu34lifeEntities();

            db.Nutritionists.Add(a);
            db.SaveChanges();
            return(true);
        }
Esempio n. 20
0
        public bool Insertar(Plan a)
        {
            var db = new Nu34lifeEntities();

            db.Plans.Add(a);
            db.SaveChanges();
            return(true);
        }
Esempio n. 21
0
        public bool Insertar(Ingredient a)
        {
            var db = new Nu34lifeEntities();

            db.Ingredients.Add(a);
            db.SaveChanges();
            return(true);
        }
Esempio n. 22
0
 public ActionResult Delete(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         Nutritionist n = db.Nutritionists.Find(id);
         db.Nutritionists.Remove(n);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Esempio n. 23
0
 public ActionResult Delete(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         Membership m = db.Memberships.Find(id);
         db.Memberships.Remove(m);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Esempio n. 24
0
 public ActionResult Delete(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         State s = db.States.Find(id);
         db.States.Remove(s);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Esempio n. 25
0
 // GET: Drug
 public ActionResult Index()
 {
     try
     {
         using (var db = new Nu34lifeEntities())
         {
             return(View(db.Drugs.ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 26
0
 // GET: Instruction
 public ActionResult Index()
 {
     try
     {
         using (var db = new Nu34lifeEntities())
         {
             var instructions = db.Instructions.Include(i => i.Recipe);
             return(View(instructions.ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 27
0
 public ActionResult Details(int?id)
 {
     if (id == null)
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         using (var db = new Nu34lifeEntities())
         {
             Instruction i = db.Instructions.Find(id);
             return(View(i));
         }
     }
 }
Esempio n. 28
0
 public ActionResult Authorize(Nu34life.Models.Nutritionist nutritionistModel)
 {
     using (var db = new Nu34lifeEntities())
     {
         var nutritionistDetails = db.Nutritionists.Where(x => x.Email == nutritionistModel.Email && x.Password == nutritionistModel.Password).FirstOrDefault();
         if (nutritionistDetails == null)
         {
             return(View("Index", nutritionistModel));
         }
         else
         {
             Session["Email"] = nutritionistDetails.Email;
             return(RedirectToAction("Index", "Home"));
         }
     }
 }
Esempio n. 29
0
 public ActionResult Edit(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         try
         {
             //Nutritionist nu = db.Nutritionists.Where(n => n.Id == id).FirstOrDefault();
             State s = db.States.Find(id);
             return(View(s));
         }
         catch (Exception ex)
         {
             throw;
         }
     }
 }
Esempio n. 30
0
        public ActionResult Create(Drug d)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (var db = new Nu34lifeEntities())
                {
                    db.Drugs.Add(d);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error al agregar el Medicamento", ex);
                return(View());
            }
        }