static void Main(string[] args) { while (true) { int SwitchCase = 0; int RoleID = 0; ContextDAL DalContext = new ContextDAL(); List <RoleBLL> RoleList = new List <RoleBLL>(); ContextBLL Context = new ContextBLL(); RoleList = Context.RoleGetAll(0, 100); for (int i = 0; i < RoleList.Count; i++) { Console.WriteLine(RoleList[i]); } Console.WriteLine("\n\nPress 1 to create a new entry"); Console.WriteLine("Press 2 to edit an entry"); Console.WriteLine("Press 3 to delete an entry"); Console.WriteLine("Press 4 to see the propertyNames of ModelDAL"); Console.WriteLine("Press 5 to see the items of Army 1"); while (!int.TryParse(Console.ReadLine(), out SwitchCase)) { Console.WriteLine("Please enter a number"); } switch (SwitchCase) { case 1: Console.WriteLine("please enter a new RoleName"); string RoleName = Console.ReadLine(); int NewRoleID = Context.RoleCreate(RoleName); Console.WriteLine($"Role nr{NewRoleID} has been created. Press a key"); Console.ReadKey(); break; case 2: Console.WriteLine("What roleNR do you want to change?"); while (!int.TryParse(Console.ReadLine(), out RoleID)) { Console.WriteLine("Please enter a number"); } Console.WriteLine("please enter a new RoleName"); RoleName = Console.ReadLine(); Context.RoleUpdate(RoleID, RoleName); Console.WriteLine($"Role nr{RoleID} has been edited. Press a key"); Console.ReadKey(); break; case 3: Console.WriteLine("What roleNR do you want to delete?"); while (!int.TryParse(Console.ReadLine(), out RoleID)) { Console.WriteLine("Please enter a number"); } Context.RoleDelete(RoleID); Console.WriteLine($"Role nr{RoleID} has been deleted. Press a key"); Console.ReadKey(); break; case 4: Console.WriteLine("\r\n\r\n"); var type = typeof(ModelDAL); System.Reflection.PropertyInfo[] Properties = type.GetProperties(); for (int i = 0; i < Properties.Length; i++) { Console.WriteLine(Properties[i].Name); } Console.ReadKey(); break; case 5: Console.WriteLine("\r\n\r\n"); List <ArmyModelBLL> Army = new List <ArmyModelBLL>(); Army = Context.ArmyModelsFindByFactionID(1, 1, 0, 100); for (int i = 0; i < Army.Count; i++) { Console.WriteLine(Army[i].ToString()); } Console.ReadKey(); break; default: Console.WriteLine("please enter a valid number"); Console.ReadKey(); break; } Console.Clear(); } }
// GET: ArmyModels/Edit public ActionResult Edit(int id) { // this will show the army info, but will also show a list of models that come with the army List <ArmyModelBLL> models = null; ArmyBLL army = null; try { using (ContextBLL ctx = new ContextBLL()) { army = ctx.ArmyFindByID(id); if (army == null) { return(View("NotFound")); } models = ctx.ArmyModelsFindByFactionID(army.ArmyID, army.FactionID, Constants.DefaultPageNumber, Constants.DefaultPageSize); #region Pulldown Stuff //We want to make pull down menus for models so we can easily select the quantity and //amount of full squats we can select. These menus are restricted by the field allowence. List <List <SelectListItem> > FieldAllowance = new List <List <SelectListItem> >(); List <List <SelectListItem> > FullSquats = new List <List <SelectListItem> >(); ViewBag.MaxFieldAllowance = FieldAllowance; ViewBag.MaxFullSquats = FullSquats; for (int i = 0; i < models.Count; i++) { FieldAllowance.Add(new List <SelectListItem>()); FullSquats.Add(new List <SelectListItem>()); int MaxQuantity = 0; if (0 != models[i].AttachesToModelID) { // limits the attached models to qty of parent model ArmyModelBLL OriginalModel = ctx.ArmyModelsFindByArmyIDAndModelID(army.ArmyID, models[i].AttachesToModelID); MaxQuantity = OriginalModel.Quantity; } else { MaxQuantity = models[i].FieldAllowence; } for (int j = 0; j < MaxQuantity + 1; j++) { //this is the list for the quantity SelectListItem sli = new SelectListItem(); sli.Text = j.ToString(); sli.Value = j.ToString(); if (j == models[i].Quantity) { sli.Selected = true; } FieldAllowance[i].Add(sli); } for (int jj = 0; jj < models[i].Quantity + 1; jj++) { // this is the list for the Full squats. we limit this to the quantity , // since full squat is an upgrade to a squat // it makes no sense to make a selection larger then the amount of squats. SelectListItem sli = new SelectListItem(); sli.Text = jj.ToString(); sli.Value = jj.ToString(); if (jj == models[i].FullSquats) { sli.Selected = true; } FullSquats[i].Add(sli); } } #endregion Pulldown stuff } } catch (Exception oops) { //error logger and divert to error screen Error.Log(oops); return(View("error", oops)); } FullArmyData item = new FullArmyData(army, models); item.models = models; if (!IsMineOrAdmin(item)) { // check if user should be editing this return(View("Porpoise")); } return(View(item)); }