private IHttpActionResult CreateUser(StarWarsUserCreationModel model)
        {
            Team team = new Team
            {
                Name = model.Name,
            };
            User user = new User
            {
                Name = model.Name,
                PhoneNumber = model.PhoneNo,
                Team = team,
            };
            

            using (TreasureContext db = new TreasureContext())
            {
                db.Teams.Add(team);
                db.Users.Add(user);
                db.SaveChanges();
                
                Dictionary<int, Page> pages = (from p in db.Page select p).ToDictionary(p=>p.PageID);
                

                int pointID = user.UserID%4;
                if (pointID%2 == 0) 
                    team.CurrentPage = pages[2];
                else
                    team.CurrentPage = pages[pointID];

                db.SaveChanges();

                return Ok(new StarWarsUserCreationViewModel{UserID = user.UserID});
            }
        }
        public ActionResult InitialSetup()
        {
            TreasureContext db = new TreasureContext();

            Team team = new Team
            {
                CurrentPage = new Page{PageID=1},
                Name = "Team Win",
            };
            User rupesh = new User
            {
                Name = "Rupesh",
                PhoneNumber = "+447796616402",
                Team = team
            };
            User stu = new User
            {
                Name = "Rupesh",
                PhoneNumber = "+447796616402",
                Team = team
            };

            Page page1 = new Page();
            page1.Items.Add(new BasicSingleActionPageItem
            {
                ExpectedInput = "Hello",
                CorrectResponse = "Mary’s father has 5 daughters – Nana, Nene, Nini, Nono. What is the fifth daughters name?",
                IncorrectResponse = "Mary’s father has 5 daughters – Nana, Nene, Nini, Nono. What is the fifth daughters name?",
                ExpectedInputNumber = "+441506243065",
                NextPage = new Page{PageID = 2},
                Interaction = InteractionType.TextMessage,
            });
            Page page2 = new Page();
            page2.Items.Add(new BasicSingleActionPageItem
            {
                ExpectedInput = "Mary",
                CorrectResponse = "Hurrah!",
                IncorrectResponse = "No!",
                ExpectedInputNumber = "+441506243065",
                Interaction = InteractionType.TextMessage,
                NextPage = new Page{PageID = 2},
            });

            db.Teams.Add(team);
            db.Users.Add(rupesh);
            db.Users.Add(stu);

            db.Page.Add(page1);
            db.Page.Add(page2);

            db.SaveChanges();

            return Json("Done", JsonRequestBehavior.AllowGet);
        }
 public void AddNotesToTeam(Team team, IEnumerable<PageItemCaseNote> notes)
 {
     if (notes == null || !notes.Any()) return;
     if (team.TeamCaseNotes==null) team.TeamCaseNotes = new List<TeamCaseNote>();
     foreach (PageItemCaseNote note in notes)
     {
         team.TeamCaseNotes.Add(new TeamCaseNote
         {
             Team = team,
             Note = note.Note,
         });
     }
 }