public ActionResult Create(Medical_Contributions_Allocations_Entry model, string command, string command2)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Medical_Contributions_Allocations_Entry record = new Medical_Contributions_Allocations_Entry();
                    record.Code  = model.Code;
                    record.Name  = model.Name;
                    record.TName = model.TName;
                    if (model.Allowed_To == 0)
                    {
                        TempData["Message"] = "Please Complete in Allowed To";
                        return(View(model));
                    }
                    else
                    {
                        record.Allowed_To      = model.Allowed_To;
                        record.Is_Contribution = model.Is_Contribution;

                        var allocations = dbcontext.Medical_Contributions_Allocations_Entry.Add(record);

                        dbcontext.SaveChanges();

                        if (command == "Submit")
                        {
                            return(RedirectToAction("Create", "Medical_Contributions_Allocations_Services", new { id = allocations.ID }));
                        }
                        if (command2 == "Submit")
                        {
                            return(RedirectToAction("Create", "Medical_Contributions_Allocations_Services", new { id = allocations.ID }));
                        }
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    return(View(model));
                }
            }
            catch (DbUpdateException)
            {
                TempData["Message"] = "this code Is already exists";
                return(View(model));
            }
            catch (Exception e)
            {
                return(View(model));
            }
        }
        public ActionResult Create()
        {
            var stru  = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Medical);
            var model = dbcontext.Medical_Contributions_Allocations_Entry.ToList();
            var count = 0;

            if (model.Count() == 0)
            {
                count = 1;
            }
            else
            {
                var te = model.LastOrDefault().ID;
                count = te + 1;
            }

            var model_ = new Medical_Contributions_Allocations_Entry {
                Code = stru.Structure_Code + count
            };

            return(View(model_));
        }
 public ActionResult Edit(Medical_Contributions_Allocations_Entry model, string command, string command2)
 {
     try
     {
         var record = dbcontext.Medical_Contributions_Allocations_Entry.FirstOrDefault(m => m.ID == model.ID);
         record.Code  = model.Code;
         record.Name  = model.Name;
         record.TName = model.TName;
         if (model.Allowed_To == 0)
         {
             TempData["Message"] = "Please Complete in Allowed To";
             return(View(model));
         }
         else
         {
             record.Allowed_To      = model.Allowed_To;
             record.Is_Contribution = model.Is_Contribution;
             dbcontext.SaveChanges();
         }
         //if (command == "Submit")
         //{
         //    return RedirectToAction("Create", "Authorities", new { id = Authority_Type.ID });
         //}
         //if (command2 == "Submit")
         //{
         //    return RedirectToAction("Create", "Authorities", new { id = Authority_Type.ID });
         //}
         return(RedirectToAction("Index"));
     }
     catch (DbUpdateException)
     {
         TempData["Message"] = "this code Is already exists";
         return(View(model));
     }
     catch (Exception e)
     { return(View(model)); }
 }