public ActionResult Edit(Medical_Service model)
        {
            try
            {
                ViewBag.Medical_Service_Classification = dbcontext.Medical_Service_Classification.ToList().Select(m => new { Code = m.Classification_Code + "-----[" + m.Description + ']', ID = m.ID });
                if (model.Medical_Service_ClassificationId == "0" || model.Medical_Service_ClassificationId == null)
                {
                    ModelState.AddModelError("", "Medical Service Classification Code must enter");
                    return(View(model));
                }
                var record = dbcontext.Medical_Service.FirstOrDefault(m => m.ID == model.ID);
                //record.Code = model.Code;
                record.Service_Code = model.Service_Code;
                record.Name         = model.Name;
                record.TName        = model.TName;
                record.Medical_Service_ClassificationId = model.Medical_Service_ClassificationId;
                var Medical_Service_ClassificationId = int.Parse(model.Medical_Service_ClassificationId);
                record.Medical_Service_Classification = dbcontext.Medical_Service_Classification.FirstOrDefault(m => m.ID == Medical_Service_ClassificationId);

                dbcontext.SaveChanges();
                return(RedirectToAction("index"));
            }
            catch (DbUpdateException)
            {
                TempData["Message"] = "This code Is already exists";
                return(View(model));
            }
            catch (Exception e)
            { return(View(model)); }
        }
 public ActionResult Create(string id)
 {
     ViewBag.Medical_Service_Classification = dbcontext.Medical_Service_Classification.ToList().Select(m => new { Code = m.Classification_Code + "-----[" + m.Description + ']', ID = m.ID });
     if (id != null)
     {
         var ID = int.Parse(id);
         var Medical_Service_Classification = dbcontext.Medical_Service_Classification.FirstOrDefault(m => m.ID == ID);
         var model = new Medical_Service {
             Medical_Service_Classification = Medical_Service_Classification, Medical_Service_ClassificationId = Medical_Service_Classification.ID.ToString()
         };
         return(View(model));
     }
     return(View());
 }