예제 #1
0
        // GET: Users/Create
        [MustBeInRole(Roles = Constants.AdministratorRoleName)] public ActionResult Create()
        {
            List <SelectListItem> item = new List <SelectListItem>();

            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    List <RoleBLL> roles = ctx.RoleGetAll(0, 100);
                    ViewBag.ListItems = item;
                    foreach (RoleBLL role in roles)
                    {
                        SelectListItem i = new SelectListItem();
                        i.Text  = role.RoleName;
                        i.Value = role.RoleID.ToString();
                        item.Add(i);
                    }
                }
            }
            catch (Exception oops)
            {
                Error.Log(oops);
                return(View("Error", oops));
            }
            return(View());
        }
예제 #2
0
        public ActionResult Impersonate(int id)
        {
            UserBLL user;

            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    user = ctx.FindUserByID(id);
                    if (null == user)
                    {
                        return(View("ItemNotFound")); // BKW make this view
                    }
                    Session["AUTHUsername"] = user.EMail;
                    Session["AUTHRoles"]    = user.RoleName;
                    Session["AUTHTYPE"]     = $"IMPERSONATED:{user.UserID}";
                }
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex;
                return(View("Error"));
            }

            return(RedirectToAction("Index", "Home"));
        }
        // GET: Role/Edit/5
        public ActionResult Edit(int id)
        {
            OwnedItemBLL Model;

            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    Model = ctx.FindOwnedItemByID(id);
                    if (null == Model)
                    {
                        return(View("ItemNotFound")); // BKW make this view
                    }
                    if (!IsThisMine(ctx, Model))
                    {
                        return(View("NotYourItem"));
                    }
                    ViewBag.Users = GetUserItems(ctx);
                }
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex;
                return(View("Error"));
            }

            return(View("..\\Item\\Edit", Model));
        }
 //// GET: Users/Create
 //[Models.Filter.MustBeInRole(Roles = Constants.Admin)]
 public ActionResult Create()
 {
     {
         try
         {
             ContextBLL            dtr   = new ContextBLL();
             List <SelectListItem> items = new List <SelectListItem>();
             ViewBag.ListItems = items;
             UserBLL newUser = new UserBLL();
             newUser.UserID   = 0;
             newUser.UserName = null;
             newUser.Email    = null;
             newUser.Hash     = null;
             newUser.Salt     = null;
             newUser.RoleID   = 0;
             List <RoleBLL> roles = dtr.RolesGetAll(0, 100);
             foreach (RoleBLL role in roles)
             {
                 SelectListItem item = new SelectListItem();
                 item.Text  = role.RoleName;
                 item.Value = role.RoleID.ToString();
                 items.Add(item);
             }
             return(View(newUser));
         }
         catch (Exception ex)
         {
             Logger.Log(ex);
             return(View("Error", ex));
         }
     }
 }
 public ActionResult Create()
 {
     {
         try
         {
             using (ContextBLL dtr = new ContextBLL())
             {
                 List <SelectListItem> items     = new List <SelectListItem>();
                 FigureBLL             newFigure = new FigureBLL();
                 newFigure.FigureDOB = DateTime.Now.Date;
                 newFigure.FigureDOD = DateTime.Now.Date;
                 List <CivilizationBLL> civs = dtr.CivilizationsGetAll(0, 100);
                 foreach (CivilizationBLL civ in civs)
                 {
                     SelectListItem item = new SelectListItem();
                     item.Text  = civ.CivName;
                     item.Value = civ.CivID.ToString();
                     items.Add(item);
                 }
                 ViewData["ListItems"] = items;
                 return(View(newFigure));
             }
         }
         catch (Exception ex)
         {
             Logger.Log(ex);
             return(View("Error", ex));
         }
     }
 }
        // GET: Item
        public ActionResult Page(int PageNumber, int PageSize)
        {
            ViewBag.PageNumber = PageNumber;
            ViewBag.PageSize   = PageSize;
            List <OwnedItemBLL> Model = new List <OwnedItemBLL>();

            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    UserBLL ThisUser = ctx.FindUserByEMail(User.Identity.Name);
                    if (null == ThisUser)
                    {
                        ViewBag.Exception = new Exception($"Could Not Find Record for User: {User.Identity.Name}");
                        return(View("Error"));
                    }
                    ViewBag.TotalCount = ctx.ObtainCountOfItemsOwnedByUser(ThisUser.UserID);
                    Model         = ctx.GetOwnedItemsRelatedToUser(ThisUser.UserID, PageNumber * PageSize, PageSize);
                    ViewBag.Users = GetUserItems(ctx);
                }

                return(View("MyIndex", Model));
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex;
                return(View("Error"));
            }
        }
예제 #7
0
 public ActionResult Create(BusinessLogicLayer.CommentBLL collection)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(View(collection));
         }
         // TODO: Add insert logic here
         using (ContextBLL ctx = new ContextBLL())
         {
             UserBLL userRecord = ctx.FindUserByUserName(User.Identity.Name);
             if (null == userRecord)
             {
                 return(View("UserNotFound"));
             }
             collection.UserID = userRecord.UserID;
             ctx.CreateComment(collection);
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ViewBag.Exception = ex;
         return(View("Error"));
     }
 }
예제 #8
0
        // GET: ArmyModels/Delete
        // GET: Armies/Delete
        public ActionResult Delete(int id)
        {
            ArmyBLL army = null;

            try
            {            // confirmation info to see the army to delete.
                using (ContextBLL ctx = new ContextBLL())
                {
                    army = ctx.ArmyFindByID(id);
                    if (army == null)
                    {                    //if the record doesn't exist we divert them
                        return(View("NotFound"));
                    }
                    if (!IsMineOrAdmin(army))
                    {                    //if they should not be able to touch it we divert them
                        return(View("Porpoise"));
                    }
                }
            }
            catch (Exception oops)
            {
                Error.Log(oops);
                return(View("Error", oops));
            }
            return(View(army));
        }
예제 #9
0
        // GET: ArmyModels/Details

        public ActionResult Details(int id)
        {               // this will show the army info, but will also show a list of models that come with the army
                        // if this army is not owned by user and doesnt have role user is diverted.
            List <ArmyModelBLL> models = null;
            ArmyBLL             army   = null;

            try
            {            // using is used because we use an SQL connection which is high in resources
                using (ContextBLL ctx = new ContextBLL())
                {
                    army = ctx.ArmyFindByID(id);
                    if (army == null)
                    {                    // If no record is returned we divert to a custom error screen.
                        return(View("NotFound"));
                    }
                    models = ctx.ArmyModelsFindByArmyID(army.ArmyID, Constants.DefaultPageNumber, Constants.DefaultPageSize);
                }
            }
            catch (Exception oops)
            {            // if the connection fails or something else goes wrong we log the error and divert.
                Error.Log(oops);
                return(View("Error", oops));
            }
            FullArmyData item = new FullArmyData(army, models);            // item is an instance of FullArmyData!

            item.models = models;
            if (!IsMineOrAdmin(item))
            {            // if user should not see this we divert him.
                return(View("Porpoise"));
            }
            return(View(item));
        }
예제 #10
0
        // GET: ArmyModels/Create
        public ActionResult Create()
        {
            #region Pulldown Stuff
            List <SelectListItem> ListOfFactions = new List <SelectListItem>();
            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    List <FactionBLL> factions = ctx.FactionsGetAll(0, 100);
                    ViewBag.FactionList = ListOfFactions;
                    foreach (FactionBLL faction in factions)
                    {
                        SelectListItem i = new SelectListItem();
                        i.Text  = faction.FactionName;
                        i.Value = faction.FactionID.ToString();
                        ListOfFactions.Add(i);
                    }
                }
            }
            catch (Exception oops)
            {
                Error.Log(oops);
                return(View("Error", oops));
            }
            #endregion Pulldown Stuff

            return(View());
        }
예제 #11
0
        public ActionResult Create(ArmyBLL Record)
        {
            //var errors = ModelState.Values.SelectMany(v => v.Errors);
            //ModelState["ArmyID"].Errors.Clear();// These are expected to be empty so ignored
            //ModelState["UserID"].Errors.Clear();// These are expected to be empty so ignored
            if (!ModelState.IsValid)
            {
                return(View(Record));
            }
            int NewArmyID = 0;

            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    UserBLL me = ctx.UserFindByName(User.Identity.Name);
                    Record.UserID = me.UserID;
                    NewArmyID     = ctx.ArmyCreate(Record);
                }
                return(RedirectToAction("Details", new { id = NewArmyID }));
            }
            catch (Exception oops)
            {
                Error.Log(oops);
                return(View("error", oops));
            }
        }
예제 #12
0
 public ActionResult ScoreStats()
 {
     try
     {
         List <ScoreBLL>   Scores;
         List <ScoreStats> Model;
         using (ContextBLL ctx = new ContextBLL())
         {
             UserBLL ThisUser = ctx.FindUserByUserName(User.Identity.Name);
             {
                 if (null == ThisUser)
                 {
                     ViewBag.Exception = new Exception($"Count not find scores for {User.Identity.Name}");
                     return(View("Error"));
                 }
                 int TotalCount = ctx.ObtainUserScoreCount(ThisUser.UserID);
                 Scores = ctx.GetScoresReltatedToUserID(ThisUser.UserID, 0, TotalCount);
             }
             MeaningfulCalculation mc = new MeaningfulCalculation();
             Model = mc.CalculateStats(Scores);
         }
         return(View("ScoreStats", Model));
     }
     catch (Exception ex)
     {
         ViewBag.Exception = ex;
         return(View("Error"));
     }
 }
예제 #13
0
        public ActionResult Page(int?PageNumber, int?PageSize)
        {
            int PageN = (PageNumber.HasValue) ? PageNumber.Value : 0;
            int PageS = (PageSize.HasValue) ? PageSize.Value : ApplicationConfig.DefaultPageSize;

            ViewBag.PageNumber = PageNumber;
            ViewBag.PageSize   = PageSize;
            List <ScoreBLL> Model = new List <ScoreBLL>();

            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    UserBLL me = ctx.FindUserByUserName(User.Identity.Name);
                    ViewBag.TotalCount = ctx.ObtainUserScoreCount(me.UserID);
                    Model = ctx.GetScoresReltatedToUserID(me.UserID, PageN * PageS, PageS);
                }
                return(View("Index", Model));
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex;
                return(View("Error"));
            }
        }
예제 #14
0
        // Pagination for Users
        public ActionResult Page(int PageNumber, int PageSize)
        {
            ViewBag.PageNumber = PageNumber;
            ViewBag.PageSize   = PageSize;
            List <SimuuBLL> model = new List <SimuuBLL>();

            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    UserBLL currentUser = ctx.User_FindByUserName(User.Identity.Name);
                    if (null == currentUser)
                    {
                        ViewBag.Exception = new Exception($"Could Not Find Record for User: {User.Identity.Name}");
                        return(View("Error"));
                    }
                    ViewBag.TotalCount = ctx.Simuus_ObtainCountRelatedToUserID(currentUser.UserID);
                    model = ctx.Simuus_GetRelatedToUserID(currentUser.UserID, PageNumber * PageSize, PageSize);
                }
                return(View("..\\Simuu\\Index", model));
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex;
                return(View("Error"));
            }
        }
        public ActionResult Delete(int id, BusinessLogicLayer.OwnedItemBLL collection)
        {
            try
            {
                // TODO: Add insert logic here
                using (ContextBLL ctx = new ContextBLL())
                {
                    OwnedItemBLL Mine = ctx.FindOwnedItemByID(id);
                    if (null == Mine)
                    {
                        return(View("ItemNotFound"));
                    }
                    if (!IsThisMine(ctx, Mine))
                    {
                        return(View("NotYourItem"));
                    }
                    ctx.DeleteOwnedItem(id);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception Ex)
            {
                ViewBag.Exception = Ex;
                return(View("Error"));
            }
        }
        public ActionResult Delete(int id)
        {
            int             civid = id;
            CivilizationBLL deleteCiv;

            try
            {
                using (ContextBLL dtr = new ContextBLL())
                {
                    deleteCiv = dtr.CivilizationFindByID(civid);
                    if (null == deleteCiv)
                    {
                        return(View("Item not found"));
                    }
                    List <FigureBLL> items;
                    items         = dtr.FiguresGetRelatedToCivID(0, 100, civid);
                    ViewBag.items = items;
                    List <EventBLL> events;
                    events         = dtr.EventsGetRelatedToCivID(0, 100, civid);
                    ViewBag.events = events;
                    return(View(deleteCiv));
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(View("Error", ex));
            }
        }
        public ActionResult Stats()
        {
            try
            {
                List <OwnedItemBLL> Items;
                List <ItemStats>    Model;
                using (ContextBLL ctx = new ContextBLL())
                {
                    UserBLL ThisUser = ctx.FindUserByEMail(User.Identity.Name);
                    if (null == ThisUser)
                    {
                        ViewBag.Exception = new Exception($"Could Not Find Record for User: {User.Identity.Name}");
                        return(View("Error"));
                    }
                    int TotalCount = ctx.ObtainCountOfItemsOwnedByUser(ThisUser.UserID);
                    Items = ctx.GetOwnedItemsRelatedToUser(ThisUser.UserID, 0, TotalCount);


                    MeaningfulCalculator mc = new MeaningfulCalculator();
                    Model = mc.ComputeStats(Items);
                }
                return(View("..\\Item\\Stats", Model));
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex;
                return(View("Error"));
            }
        }
예제 #18
0
 public ActionResult Delete(int id)
 {
     {
         {
             RaceBLL Race;
             try
             {
                 using (ContextBLL ctx = new ContextBLL())
                 {
                     Race = ctx.FindRaceByRaceID(id);
                     if (null == Race)
                     {
                         return(View("ItemNotFound"));
                     }
                 }
             }
             catch (Exception ex)
             {
                 ViewBag.Exception = ex;
                 return(View("Error"));
             }
             return(View(Race));
         }
     }
 }
        // GET: Role/Details/5
        public ActionResult Details(int id)
        {
            OwnedItemBLL Model;

            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    Model = ctx.FindOwnedItemByID(id);
                    if (null == Model)
                    {
                        return(View("ItemNotFound"));
                    }
                    if (!IsThisMine(ctx, Model))
                    {
                        return(View("NotYourItem"));
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex;
                return(View("Error"));
            }
            return(View("..\\Item\\Details", Model));
        }
예제 #20
0
        public ActionResult Index()
        {
            ContextBLL ctx = new ContextBLL();
            var        x   = ctx.GetUsers(0, 100);

            return(View());
        }
 public ActionResult Edit(int id)
 {
     try
     {
         UserBLL user;
         List <SelectListItem> items = new List <SelectListItem>();
         ViewBag.ListItems = items;
         using (ContextBLL dtr = new ContextBLL())
         {
             user = dtr.UserFindByID(id);
             List <RoleBLL> roles = dtr.RolesGetAll(0, 100);
             foreach (RoleBLL role in roles)
             {
                 SelectListItem item = new SelectListItem();
                 item.Text  = role.RoleName;
                 item.Value = role.RoleID.ToString();
                 items.Add(item);
             }
         }
         return(View(user));
     }
     catch (Exception ex)
     {
         Logger.Log(ex);
         return(View("Error", ex));
     }
 }
예제 #22
0
        public ActionResult Create(Multi collection)
        {
            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    if (!ModelState.IsValid)
                    {
                        ViewBag.Roles   = GetRoleItems(ctx);
                        ViewBag.Races   = GetRaceItems(ctx);
                        ViewBag.Classes = GetClassItems(ctx);
                        return(View(collection));
                    }



                    int UserID = ctx.CreateUser(collection.UserName, collection.Email, collection.RoleID, collection.Password, collection.PasswordAgain, collection.NewRoleName);

                    collection.UserID = ctx.CreateCharacter(UserID, collection.CharacterName, collection.ClassID, collection.RaceID, ctx.Roll(), ctx.Roll(), ctx.Roll(), ctx.Roll(), ctx.Roll(), ctx.Roll());
                }
                return(RedirectToAction("Index", "User"));
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex;
                return(View("Error"));
            }
        }
 public ActionResult Edit(int id)
 {
     try
     {
         FigureBLL             figure;
         List <SelectListItem> items = new List <SelectListItem>();
         ViewBag.ListItems = items;
         using (ContextBLL dtr = new ContextBLL())
         {
             figure = dtr.FigureFindByID(id);
             List <CivilizationBLL> civs = dtr.CivilizationsGetAll(0, 100);
             foreach (CivilizationBLL civ in civs)
             {
                 SelectListItem item = new SelectListItem();
                 item.Text  = civ.CivName;
                 item.Value = civ.CivID.ToString();
                 items.Add(item);
             }
         }
         return(View(figure));
     }
     catch (Exception ex)
     {
         Logger.Log(ex);
         return(View("Error", ex));
     }
 }
예제 #24
0
 public ActionResult Login(LoginModel info)
 {
     using (ContextBLL ctx = new ContextBLL())
     {
         if (!ModelState.IsValid)
         {
             return(View(info));
         }
         UserBLL user = ctx.FindUserByUsername(info.Username);
         if (user == null)
         {
             info.message = $"The Username '{info.Username}' does not exist in the database";
             return(View(info));
         }
         string actual = user.Password;
         //string potential = user.Salt + info.Password;
         string potential = info.Password;
         //bool validateduser = System.Web.Helpers.Crypto.VerifyHashedPassword(actual,potential);
         bool validateduser = actual == potential;
         if (validateduser)
         {
             Session["AUTHUsername"] = user.Username;
             Session["AUTHRoles"]    = user.RoleID.ToString();
             return(Redirect(info.ReturnURL));
         }
         info.message = "The password was incorrect";
         return(View(info));
     }
 }
예제 #25
0
 // GET: MovieUser
 public ActionResult Index()
 {
     using (ContextBLL ctx = new ContextBLL())
     {
         return(View(ctx.GetMovieUsers(0, 100)));
     }
 }
        public ActionResult Edit(int id, BusinessLogicLayer.OwnedItemBLL collection)
        {
            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    OwnedItemBLL Mine = ctx.FindOwnedItemByID(collection.OwnedItemID);
                    if (null == Mine)
                    {
                        return(View("ItemNotFound"));
                    }
                    if (!IsThisMine(ctx, Mine))
                    {
                        return(View("NotYourItem"));
                    }

                    ctx.UpdateOwnedItem(collection);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception Ex)
            {
                ViewBag.Exception = Ex;
                return(View("Error"));
            }
        }
예제 #27
0
        // GET: Users/Edit/5
        [MustBeInRole(Roles = Constants.AdministratorRoleName)] public ActionResult Edit(int id)
        {
            UserBLL User = null;
            List <SelectListItem> item = new List <SelectListItem>();

            try
            {
                using (ContextBLL ctx = new ContextBLL())
                {
                    User = ctx.UserFindByID(id);
                    if (User == null)
                    {
                        return(View("NotFound"));
                    }
                    List <RoleBLL> roles = ctx.RoleGetAll(0, 100);
                    ViewBag.ListItems = item;
                    foreach (RoleBLL role in roles)
                    {
                        SelectListItem i = new SelectListItem();
                        i.Text  = role.RoleName;
                        i.Value = role.RoleID.ToString();
                        item.Add(i);
                    }
                }
            }
            catch (Exception oops)
            {
                Error.Log(oops);
                return(View("Error", oops));
            }
            return(View(User));
        }
 public ActionResult SimulateDALProcedureNotFound()
 {
     using (ContextBLL ctx = new ContextBLL())
     {
         ctx.GenerateStoredProcedureNotFound();
         return(View());
     }
 }
 public ActionResult SimulateDALParameterNotFound()
 {
     using (ContextBLL ctx = new ContextBLL())
     {
         ctx.GenerateParameterNotIncluded();
         return(View());
     }
 }
 public ActionResult SimulateDALNotConnected()
 {
     using (ContextBLL ctx = new ContextBLL())
     {
         ctx.GenerateNotConnected();
         return(View());
     }
 }