Skip to content

GarrettGibbs/Live-Project-Summary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 

Repository files navigation

Live Project

Introduction

I had the opportunity to work on a project with several other interns and seasoned professionals acting as a team. I have had numerous opportunities to work on fixing bugs, cleaning up code, and adding requested features, as well as working within a group and using version control in a completely comprehensive way. We were tasked with working on a theater company's full scale MVC Web Application in C#. Over the course of this project I had the opportunity to work on skills that I'm confident I will use again and again on future endeavors.

Below are descriptions of some of the stories I worked on, along with code snippets, screenshots and navigation links.

Jump to: Front End Stories, Back End Stories, Other Skills

Back End Stories

Auto Implement Admin Settings

I was tasked with editing the Admin Controller, to automatically update the entries in the subscriber and productions databases when the admin updated certain settings that are set to a JSON file. After updating the SettingsUpdate method to determine if certain settings were changed, it would call new Methods to loop through the entries in their respective databases and update the set property.

   [HttpPost]
        public ActionResult SettingsUpdate(AdminSettings currentSettings)
        {
            string newSettings = JsonConvert.SerializeObject(currentSettings, Formatting.Indented);
            newSettings = newSettings.Replace("T00:00:00", "");
            string filepath = Server.MapPath(Url.Content("~/AdminSettings.json"));
            string oldSettings = null;
        using (StreamReader reader = new StreamReader(filepath))
        {
           oldSettings = reader.ReadToEnd();
        }
        dynamic oldJSON = JObject.Parse(oldSettings);
        dynamic newJSON = JObject.Parse(newSettings);
        if (oldJSON.recent_definition.date != newJSON.recent_definition.date)
        {
            UpdateSubscribers(newJSON);
        }
        if (oldJSON.season_productions != newJSON.season_productions)
        {
            UpdateProductions(newJSON);
        }
        using (StreamWriter writer = new StreamWriter(filepath))
        {
            writer.Write(newSettings);
            return RedirectToAction("Dashboard");
        }
    }

    private void UpdateSubscribers(dynamic newJSON)
    {
        DateTime recentDef = newJSON.recent_definition.date;
        foreach (var subscriber in db.Subscribers)
        {
            if (recentDef >= subscriber.LastDonated)
            {
                subscriber.RecentDonor = false;
            }
            else
            {
                subscriber.RecentDonor = true;
            }
        }
        db.SaveChanges();
    }

    private void UpdateProductions(dynamic newJSON)
    {
        int fall = newJSON.season_productions.fall;
        int winter = newJSON.season_productions.winter;
        int spring = newJSON.season_productions.spring;
        foreach (var production in db.Productions)
        {
            if (production.ProductionId == fall || production.ProductionId == winter || production.ProductionId == spring)
            {
                production.IsCurrent = true;
            }
            else
            {
                production.IsCurrent = false;
            }
        }
        db.SaveChanges();
    }       

Create New Subscriber

While working on the Subscriber Create Page I needed to ensure that the form from the view was being properly submitted and the controller would successfully create a new subscriber to the database. While doing so, the main obstacle I ran into was how to deal with the user being in a normal role or admin role. If they were signed in as the admin they could select which account they wanted to make a subscriber and that would be passed to the controller, but if not then it should just take the current user's information. I created an if statment within the controller that would decide between the two and take the appropriate action afterwards.

  [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "SubscriberId,CurrentSubscriber,HasRenewed,Newsletter,RecentDonor,LastDonated,LastDonationAmt,SpecialRequests,Notes")]  Subscriber subscriber)
        {
        //The form sent the user's User selection (from SelectList) into the POST method
        //Remove the SubscriberPerson from ModelState, at dbo.Subscribers has no such column
        ModelState.Remove("SubscriberPerson");

        //Extract the Guid as type String from user's selected User (from SelectList)
        string userId = null;

        if (User.IsInRole("Admin"))
        {
            userId = Request.Form["dbUsers"].ToString();
        }
        else 
        { 
            userId = User.Identity.GetUserId();
        }

        if (ModelState.IsValid)
        {
          
            //See tutorials for why SelectList is loaded here as well
            ViewData["dbUsers"] = new SelectList(db.Users.ToList(), "Id", "UserName");

            //LINQ statemenet to query the Guid (via String) of the user's selected User
            subscriber.SubscriberPerson = db.Users.Find(userId);

            //create instance of UserManager class &add user to "Subscriber" role
            var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db));

            if (userManager.GetRoles(userId).Count < 1)
            {
                userManager.AddToRole(userId, "Subscriber");
            }

            //Add Subscriber to database, linked with User and save changes
            try
            {
                db.Subscribers.Add(subscriber);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            catch
            {
                ViewBag.SubscriberError = "Sorry, there was an error submitting this form.";
                return View("Create");
            }
            
        }
        return View(subscriber);
    }    

Jump to: Front End Stories, Back End Stories, Other Skills, Page Top

Front End Stories

Subscriber NavBar

I needed to create a navbar for the Subscriber Area. It presented a new task to me as the subscriber area is sequestered from the rest of the project, so navigating between the two took some added lines. Also, I got to hone my skills with responsiveness and working with bootstrap's collapse classes.

Login Failure Page

I was given a very open ended story to improve the styling of the login failure page. I switched the colors to match the overall theme of the website, as well as creating buttons that could be used on several different pages throughout.

Subscriber Create Page

There were two parts to this story. First I noticed that someone had accidently overridden a bootstrap class which was causing the contents to be invisible, so I was able to adjust that and give the page some basic styling. Second, I needed to create different views depending on the user's access privileges.

All Productions Page

The original page had all the productions listed one after the other on the left hand side of the page, which did not look good and was impratical. First I utilized bootstraps column system to make use of the entire page, I also changed the styling to give a cleaner look. Then I made the details link to clicking on the picture, rather than a button, and set the CRUD functions to only be visible when the user was signed in as an admin. Finally, I adjusted it so that the page would better respond to the screen size, going from three down to two per row, and finally displaying them all in one on mobile view.

Jump to: Front End Stories, Back End Stories, Other Skills, Page Top

Other Skills Learned

  • Working with a group of developers to identify front and back end bugs to improve usability of an application
  • Improving project flow by communicating about who is working in what areas and how to best navigate the project as a whole
  • Learning new efficiencies from other developers by observing their workflow and asking questions
  • Practice with team programming/pair programming when one developer runs into a bug they cannot immediately solve

Jump to: Front End Stories, Back End Stories, Other Skills, Page Top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors