Exemple #1
0
        public ActionResult Create([Bind(Include = "HCID,Center,Latitude,Longtitude,District,Parish")] Health_Center health_Center)
        {
            var    query = db.Health_Centers.Count() + 1;
            string temp  = "HC-" + query;
            bool   exist = false;

            try
            {
                var search = db.Health_Centers.Where(c => c.HCID == temp).Single();
                exist = true;
            }
            catch
            {
                exist = false;
            }
            if (exist)
            {
                var all = db.Health_Centers.ToList();
                var HC  = all.Last();
                HC.HCID = "HC-" + DataModels.DataProcess.NextNumber(HC.HCID);
            }
            else
            {
                health_Center.HCID = temp;
            }
            if (ModelState.IsValid)
            {
                db.Health_Centers.Add(health_Center);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(health_Center));
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(string id)
        {
            Health_Center health_Center = db.Health_Centers.Find(id);

            db.Health_Centers.Remove(health_Center);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "HCID,Center,Latitude,Longtitude,District,Parish")] Health_Center health_Center)
 {
     if (ModelState.IsValid)
     {
         db.Entry(health_Center).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(health_Center));
 }
Exemple #4
0
        // GET: Health_Center/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Health_Center health_Center = db.Health_Centers.Find(id);

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