Beispiel #1
0
        private ProjectDTO Create(ProjectViewModel viewModel)
        {
            try
            {
                log.Debug(ProjectViewModel.FormatProjectViewModel(viewModel));

                ProjectDTO project = new ProjectDTO();

                // copy values
                viewModel.UpdateDTO(project, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                project.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                project.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_projectService.AddProject - " + ProjectDTO.FormatProjectDTO(project));

                int id = _projectService.AddProject(project);

                project.ProjectId = id;

                log.Debug("result: 'success', id: " + id);

                return(project);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Beispiel #2
0
        public ProjectDTO GetProject(int projectId)
        {
            try
            {
                //Requires.NotNegative("projectId", projectId);

                log.Debug("projectId: " + projectId + " ");

                // get
                R_Project t = Repository.GetProject(projectId);

                ProjectDTO dto = new ProjectDTO(t);

                log.Debug(ProjectDTO.FormatProjectDTO(dto));

                return(dto);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Beispiel #3
0
        public int AddProject(ProjectDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(ProjectDTO.FormatProjectDTO(dto));

                R_Project t = ProjectDTO.ConvertDTOtoEntity(dto);

                // add
                id            = Repository.AddProject(t);
                dto.ProjectId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
Beispiel #4
0
        private ProjectDTO Update(ProjectViewModel viewModel)
        {
            try
            {
                log.Debug(ProjectViewModel.FormatProjectViewModel(viewModel));

                // get
                log.Debug("_projectService.GetProject - projectId: " + viewModel.ProjectId + " ");

                var existingProject = _projectService.GetProject(viewModel.ProjectId);

                log.Debug("_projectService.GetProject - " + ProjectDTO.FormatProjectDTO(existingProject));

                if (existingProject != null)
                {
                    // copy values
                    viewModel.UpdateDTO(existingProject, null); //RequestContext.Principal.Identity.GetUserId());

                    // update
                    log.Debug("_projectService.UpdateProject - " + ProjectDTO.FormatProjectDTO(existingProject));

                    _projectService.UpdateProject(existingProject);

                    log.Debug("result: 'success'");
                }
                else
                {
                    log.Error("existingProject: null, ProjectId: " + viewModel.ProjectId);
                }

                return(existingProject);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Beispiel #5
0
        public void DeleteProject(ProjectDTO dto)
        {
            try
            {
                log.Debug(ProjectDTO.FormatProjectDTO(dto));

                R_Project t = ProjectDTO.ConvertDTOtoEntity(dto);

                // delete
                Repository.DeleteProject(t);
                dto.IsDeleted = t.IsDeleted;

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Beispiel #6
0
        public void UpdateProject(ProjectDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "ProjectId");

                log.Debug(ProjectDTO.FormatProjectDTO(dto));

                R_Project t = ProjectDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateProject(t);

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }