public void AddNewProject_ValidProject_ReturnsAllProjects()
        {
            bool isValidTask = false;

            while (!isValidTask)
            {
                var TaskId = new Random().Next();

                var TaskInDb = _ProjectsController.GetProject(TaskId);
                if (TaskInDb.GetType() == typeof(NotFoundResult))
                {
                    isValidTask = true;

                    var Task = new DAL.Project()
                    {
                        Project_ID  = TaskId,
                        StartDate   = DateTime.Now.AddDays(1),
                        EndDate     = DateTime.Now.AddDays(2),
                        Priority    = 1,
                        ProjectName = "Test_Nunit",
                    };
                    IHttpActionResult actionResult = _ProjectsController.PostProject(Task);
                    var contentResult = ((System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult <ProjectManagement.DAL.Project>)actionResult);

                    Assert.IsNotNull(contentResult);
                    Assert.IsNotNull(contentResult.Content);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Inserts the project.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <returns></returns>
        public override void Insert(Project project)
        {
            DAL.Project dalProject = new DAL.Project
            {
                ActEndDate  = project.ActEndDate,
                Description = project.Description,
                ExpEndDate  = project.ExpEndDate,
                Name        = project.Name,
                StartDate   = project.StartDate
            };
            dalProject.Save();

            project.ID = dalProject.Id;
        }
        public List <ModelDomain.UserProject> GetUserProject(int userId)
        {
            List <ModelDomain.UserProject> result = new List <ModelDomain.UserProject>();

            if (userId > 0)
            {
                var optionsBuilder = new DbContextOptionsBuilder <CodeChallengeContext>();
                optionsBuilder.UseSqlServer(sqlConnection);

                using (CodeChallengeContext contex = new CodeChallengeContext(optionsBuilder.Options))
                {
                    //get the user data
                    DAL.User user = contex.User.Where(u => u.Id == userId).Single();

                    //include("User").Include("Project") or a Select with joins of just the required field is faster,
                    //just doing example of multiple DB access in a BLL

                    List <DAL.UserProject> resultDB = contex.UserProject.Where(e => e.UserId == userId).ToList();

                    resultDB.ForEach(e =>
                    {
                        ModelDomain.UserProject uResult = new ModelDomain.UserProject();

                        uResult.AssignedDate = e.AssignedDate;
                        uResult.IsActive     = e.IsActive;

                        uResult.User           = new ModelDomain.User();
                        uResult.UserId         = user.Id;
                        uResult.User.Id        = user.Id;
                        uResult.User.FirstName = user.FirstName;
                        uResult.User.LastName  = user.LastName;

                        //get project from DB
                        DAL.Project project = contex.Project.Where(p => p.Id == e.ProjectId).Single();
                        uResult.Project     = new ModelDomain.Project();

                        uResult.ProjectId         = project.Id;
                        uResult.Project.Id        = project.Id;
                        uResult.Project.StartDate = project.StartDate;
                        uResult.Project.EndDate   = project.EndDate;
                        uResult.Project.Credits   = project.Credits;

                        result.Add(uResult);
                    });
                }
            }
            return(result);
        }
Esempio n. 4
0
 protected override Project CreateRecord(IActiveRecord activeRecord)
 {
     DAL.Project dalProject = (DAL.Project)activeRecord;
     return(new Project(dalProject.Id, dalProject.Name, dalProject.Description, dalProject.StartDate,
                        dalProject.ExpEndDate, dalProject.ActEndDate));
 }
Esempio n. 5
0
 public List <DAL.Project> UpdateProject(DAL.Project objProject)
 {
     throw new NotImplementedException();
 }