Esempio n. 1
0
        public ActionResult Delete(string id, FormCollection collection)
        {
            bool   DidItWork  = false;
            string CrudAction = "Delete";

            try
            {
                TeamAttributePermissionBusinessLayer bl = new TeamAttributePermissionBusinessLayer();
                TeamAttributePermission a = bl.TeamAttributePermissions.Where(p => p.ID == id).Single();

                StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer();
                DidItWork = spbl.ExecuteStoredProcedure(a, CrudAction, User.Identity.Name);
                if (DidItWork == false)
                {
                    return(Content(string.Format("Error on {0} of {1}. Press back to return and try again", CrudAction, a.GetType().Name)));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 2
0
        // GET: TeamAttributePermission/Delete/5
        public ActionResult Delete(string id)
        {
            TeamAttributePermissionBusinessLayer bl = new TeamAttributePermissionBusinessLayer();
            TeamAttributePermission o = bl.TeamAttributePermissions.Where(p => p.ID == id).Single();

            return(View(o));
        }
Esempio n. 3
0
        public ActionResult Edit(string id, FormCollection collection)
        {
            bool   DidItWork  = false;
            string CrudAction = "Edit";

            try
            {
                TeamAttributePermissionBusinessLayer bl = new TeamAttributePermissionBusinessLayer();
                TeamAttributePermission a = bl.TeamAttributePermissions.Where(p => p.ID == id).Single();

                #region Pull from Form Collection
                a.ReadPermission    = Convert.ToInt32(collection["ddRead"]);
                a.WritePermission   = Convert.ToInt32(collection["ddWrite"]);
                a.Notify            = Convert.ToInt32(collection["ddNotify"]);
                a.ViewChange        = Convert.ToInt32(collection["ddView"]);
                a.ParkForQuarantine = Convert.ToInt32(collection["ddPark"]);
                #endregion

                StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer();
                DidItWork = spbl.ExecuteStoredProcedure(a, CrudAction, User.Identity.Name);
                if (DidItWork == false)
                {
                    return(Content(string.Format("Error on {0} of {1}. Press back to return and try again", CrudAction, a.GetType().Name)));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 4
0
        // GET: TeamAttributePermission
        public ActionResult Index()
        {
            TeamAttributePermissionBusinessLayer bl = new TeamAttributePermissionBusinessLayer();
            List <TeamAttributePermission>       ListOfTeamAttributePermissions = bl.TeamAttributePermissions.OrderBy(o => o.TeamID).ToList();

            return(View(ListOfTeamAttributePermissions));
        }
        // GET: AttributeValue/Create
        public ActionResult Create(int Sfid = 0, int SeasonID = 0)
        {
            #region StaticDropdowns
            SeasonBusinessLayer sbl           = new SeasonBusinessLayer();
            List <Season>       ListOfSeasons = sbl.Seasons.Where(r => r.SeasonActive == 1).OrderBy(o => o.FirstLaunchDate).ToList();
            ViewData["ddSeason"] = ListOfSeasons.Select(m => new SelectListItem {
                Value = m.SeasonID.ToString(), Text = m.SeasonDesc + " (" + m.SeasonID.ToString() + ")", Selected = m.SeasonID == SeasonID
            });

            AttributeBusinessLayer abl = new AttributeBusinessLayer();
            List <BusinessLayerLibrary.Attribute> ListOfAttributes = abl.Attributes.Where(w => w.Calculated == 0).OrderBy(o => o.AttributeOrder).ToList();

            //exclude attributes that already have values
            AttributeValueBusinessLayer           rbl = new AttributeValueBusinessLayer();
            List <AttributeValue>                 ListOfAttributeValues     = rbl.AttributeValues.Where(r => r.SFID == Sfid && r.SeasonID == SeasonID).ToList();
            List <BusinessLayerLibrary.Attribute> ListOfPopulatedAttributes = ListOfAttributeValues.Select(q => new BusinessLayerLibrary.Attribute {
                AttributeID = q.AttributeID
            }).ToList();
            ListOfAttributes = ListOfAttributes.Except(ListOfPopulatedAttributes, new Compare.LambdaComparer <BusinessLayerLibrary.Attribute>((x, y) => x.AttributeID == y.AttributeID)).ToList();

            //include only attributes that the user has write permissions for
            //work out what team the user is in
            int TeamID                       = 0;
            UserBusinessLayer ubl            = new UserBusinessLayer();
            string            ShortNetworkID = User.Identity.Name.Split('\\')[1].ToLower();
            if (ubl.Users.Any(o => o.NetworkID == ShortNetworkID))
            {
                TeamID = ubl.Users.Where(o => o.NetworkID == ShortNetworkID).Single().TeamID;
            }

            //TeamBusinessLayer tbl = new TeamBusinessLayer();
            //List<Team> WhatTeamsAmIIn = tbl.Teams(User.Identity.Name).ToList();
            TeamAttributePermissionBusinessLayer tapbl = new TeamAttributePermissionBusinessLayer();
            //List<TeamAttributePermission> WhatAttributesCanIWriteTo = tapbl.TeamAttributePermissions.Join(WhatTeamsAmIIn,a=> a.TeamID,b=>b.TeamID,(a,b) => new { a, b }).Select(z => z.a).ToList();
            List <TeamAttributePermission> WhatAttributesCanIWriteTo = tapbl.TeamAttributePermissions.Where(a => a.TeamID == TeamID).ToList();

            ListOfAttributes = ListOfAttributes.Join(WhatAttributesCanIWriteTo, a => a.AttributeID, b => b.AttributeID, (a, b) => new { a, b }).Select(z => z.a).ToList();

            ViewData["ddAttribute"] = ListOfAttributes.Select(m => new SelectListItem {
                Value = m.AttributeID.ToString(), Text = m.AttributeDesc + " (" + m.AttributeID.ToString() + ")"
            });

            ViewBag.Sfid     = Sfid;
            ViewBag.SeasonID = SeasonID;

            #endregion

            return(View());
        }
Esempio n. 6
0
        // GET: TeamAttributePermission/Edit/5
        public ActionResult Edit(string id)
        {
            TeamAttributePermissionBusinessLayer bl = new TeamAttributePermissionBusinessLayer();
            TeamAttributePermission o = bl.TeamAttributePermissions.Where(p => p.ID == id).Single();

            TeamBusinessLayer tbl         = new TeamBusinessLayer();
            List <Team>       ListOfTeams = tbl.Teams.ToList();

            ViewData["ddTeam"] = ListOfTeams.Select(m => new SelectListItem {
                Value = m.TeamID.ToString(), Text = m.TeamDesc + " (" + m.TeamID.ToString() + ")", Selected = m.TeamID == o.TeamID
            });

            AttributeBusinessLayer abl = new AttributeBusinessLayer();
            List <BusinessLayerLibrary.Attribute> ListOfAttributes = abl.Attributes.Where(w => w.Calculated == 0).OrderBy(z => z.AttributeOrder).ToList();

            ViewData["ddAttr"] = ListOfAttributes.Select(m => new SelectListItem {
                Value = m.AttributeID.ToString(), Text = m.AttributeDesc + " (" + m.AttributeID.ToString() + ")", Selected = m.AttributeID == o.AttributeID
            });



            var Items = new HashSet <SelectListItem>();

            Items.Add(new SelectListItem {
                Text = "Yes", Value = "1"
            });
            Items.Add(new SelectListItem {
                Text = "No", Value = "0"
            });
            ViewData["ddRead"] = Items.Select(m => new SelectListItem {
                Value = m.Value, Text = m.Text, Selected = o.ReadPermission.ToString() == m.Value
            });
            ViewData["ddWrite"] = Items.Select(m => new SelectListItem {
                Value = m.Value, Text = m.Text, Selected = o.WritePermission.ToString() == m.Value
            });
            ViewData["ddNotify"] = Items.Select(m => new SelectListItem {
                Value = m.Value, Text = m.Text, Selected = o.Notify.ToString() == m.Value
            });
            ViewData["ddView"] = Items.Select(m => new SelectListItem {
                Value = m.Value, Text = m.Text, Selected = o.ViewChange.ToString() == m.Value
            });
            ViewData["ddPark"] = Items.Select(m => new SelectListItem {
                Value = m.Value, Text = m.Text, Selected = o.ParkForQuarantine.ToString() == m.Value
            });

            ViewBag.ID = id;
            return(View(o));
        }