コード例 #1
0
 public void testCreateUser()
 {
     Assert.IsTrue(_TeamDataAccess.CreateNewTeam(TESTCREATETEAMDATA, TESTCREATEUSERDATA1.UserID));
     Assert.IsTrue(_UserDataAccess.CreateUser(TESTCREATEUSERDATA1, TESTCREATETEAMDATA.TeamID));
     Assert.AreEqual(TESTCREATEUSERDATA1.LastName, _UserDataAccess.GetAllUsers().Where(
                         u => u.UserID == 1 && u.FirstName == "TestUser" && u.LastName == "Test").First().LastName);
 }
コード例 #2
0
        ///<summary>
        /// Sends request to database for creating a new team
        /// </summary>
        public ActionResult AddTeam(TeamViewModel iViewModel)
        {
            ActionResult oResponse = null;
            var          userPO    = (IUserPO)Session["UserModel"];

            // Ensure user is authenticated
            if (userPO.Email != null && userPO.RoleID_FK == (int)RoleEnum.Administrator)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        // Map Team properties from presentation to data objects
                        ITeamDO lTeamForm = TeamMapper.MapTeamPOtoDO(iViewModel.Team);

                        // Passes form to AddTeam method
                        _TeamDataAccess.CreateNewTeam(lTeamForm, userPO.UserID);
                        oResponse = RedirectToAction("ViewAllTeams", "Maint");
                    }
                    catch (Exception ex)
                    {
                        ErrorLogger.LogError(ex, "AddTeam", "Maint");
                        iViewModel.ErrorMessage = "There was an issue adding a new team. Please try again. If the problem persists contact your IT department.";

                        oResponse = View(iViewModel);
                    }
                }
                else
                {
                    oResponse = View(iViewModel);
                }
            }
            else
            {
                // User doesn't have access
                oResponse = RedirectToAction("Index", "Home");
            }

            return(oResponse);
        }