Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "HT,Tip")] Health_Tip health_Tip)
        {
            var    query = db.Health_Tips.Count() + 1;
            string temp  = "HT-" + query;
            bool   exist = false;

            try
            {
                var search = db.Health_Tips.Where(c => c.HT == temp).Single();
                exist = true;
            }
            catch
            {
                exist = false;
            }
            if (exist)
            {
                var all = db.Health_Tips.ToList();
                var tip = all.Last();
                health_Tip.HT = "HT-" + DataModels.DataProcess.NextNumber(tip.HT);
            }
            else
            {
                health_Tip.HT = temp;
            }
            if (ModelState.IsValid)
            {
                db.Health_Tips.Add(health_Tip);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(health_Tip));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(string id)
        {
            Health_Tip health_Tip = db.Health_Tips.Find(id);

            db.Health_Tips.Remove(health_Tip);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "HT,Tip")] Health_Tip health_Tip)
 {
     if (ModelState.IsValid)
     {
         db.Entry(health_Tip).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(health_Tip));
 }
Exemplo n.º 4
0
        // GET: Health_Tip/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Health_Tip health_Tip = db.Health_Tips.Find(id);

            if (health_Tip == null)
            {
                return(HttpNotFound());
            }
            return(View(health_Tip));
        }