/// <summary> /// Adds mapping to project mapping table /// </summary> /// <param name="mappingModel">project mapping data</param> /// <returns>Database operation details</returns> public OperationDetails AddProjectMapping(ProjectMappingModel mappingModel) { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start."); OperationDetails operationDetails = null; try { operationDetails = new OperationDetails(); OracleParameter[] objParams = { new OracleParameter("P_PFID", mappingModel.Pfid), new OracleParameter("P_PROJECTID", mappingModel.ProjectId), new OracleParameter("P_ISPROJECTADMIN", mappingModel.IsProjectAdmin), new OracleParameter("P_CREATEDBY", mappingModel.CreatedBy) }; operationDetails = InsertUpdateRecord(objParams, "ADD_PROJECT_MAPPING"); return(operationDetails); } catch (Exception exception) { errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace); throw; } finally { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end."); } }
private ProjectDetailsViewModel GetProjectDetailsViewModel(ProjectMappingModel projectMapping) { return(new ProjectDetailsViewModel { ProjectId = projectMapping.Project.Id, ProjectName = projectMapping.Project.ProjectName, Description = projectMapping.Project.Description, IsProjectAdmin = projectMapping.IsProjectAdmin == 1 }); }
public ActionResult CreateProjectUser(ProjectUserViewModel model) { UserBL userBL = new UserBL(); OperationDetails operationDetails; UserModel user = userBL.GetUserByPfid(model.Pfid); if (user != null) { if (user.RoleId == (int)EnumHelper.Role.SuperAdmin) { return(Json(new { success = false, message = "Cannot assign project to admin user." }, JsonRequestBehavior.AllowGet)); } } else { // If user not found in User table, get user from HRMS service. user = userBL.GetUserFromService(model.Pfid); if (user == null) { return(Json(new { success = false, message = "Employee with this PFID does not exist." }, JsonRequestBehavior.AllowGet)); } user.CreatedBy = CurrentUser.Pfid; operationDetails = userBL.AddUser(user); if (operationDetails.OperationStatus != 1) { return(Json(new { success = false, message = "Something went wrong!!" }, JsonRequestBehavior.AllowGet)); } } ProjectMappingModel projectMapping = new ProjectMappingModel(); projectMapping.Pfid = model.Pfid; projectMapping.ProjectId = model.ProjectId; projectMapping.IsProjectAdmin = model.IsAdmin ? 1 : 0; projectMapping.CreatedBy = CurrentUser.Pfid; operationDetails = userBL.AddProjectMapping(projectMapping); if (operationDetails.OperationStatus == 1) { return(Json(new { success = true, message = "User added to project successfully." }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = "Something went wrong!!" }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Gets project mapped to the user with mapping and project details. /// </summary> /// <param name="pfid">PFID of user</param> /// <returns>List of project mapping</returns> public List <ProjectMappingModel> GetProjectMappingByUser(int pfid) { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start."); List <ProjectMappingModel> projectMapping = null; try { projectMapping = new List <ProjectMappingModel>(); OracleParameter[] objParams = { new OracleParameter("P_PFID", pfid) }; DataTable dtRecords = new DataTable(); dtRecords = ReadRecord(objParams, "GET_PROJECTS_BY_USER"); if (dtRecords.Rows.Count > 0) { foreach (DataRow row in dtRecords.Rows) { ProjectMappingModel projectMappingModel = new ProjectMappingModel(); projectMappingModel.Id = row["ID"] == DBNull.Value ? 0 : Convert.ToInt32(row["ID"].ToString()); projectMappingModel.Pfid = row["PFINDEXNO"] == DBNull.Value ? 0 : Convert.ToInt32(row["PFINDEXNO"].ToString()); projectMappingModel.ProjectId = row["PROJECTID"] == DBNull.Value ? 0 : Convert.ToInt32(row["PROJECTID"].ToString()); projectMappingModel.IsProjectAdmin = row["ISPROJECTADMIN"] == DBNull.Value ? 0 : Convert.ToInt32(row["ISPROJECTADMIN"].ToString()); projectMappingModel.Project.Id = row["PROJECTID"] == DBNull.Value ? 0 : Convert.ToInt32(row["PROJECTID"].ToString()); projectMappingModel.Project.ProjectName = row["PROJECTNAME"] == DBNull.Value ? "" : row["PROJECTNAME"].ToString(); projectMappingModel.Project.Description = row["PROJECTDESCRIPTION"] == DBNull.Value ? "" : row["PROJECTDESCRIPTION"].ToString(); projectMappingModel.Project.IsActive = row["ISACTIVE"] == DBNull.Value ? 0 : Convert.ToInt32(row["ISACTIVE"].ToString()); projectMapping.Add(projectMappingModel); } } } catch (Exception exception) { errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace); throw; } finally { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end."); } return(projectMapping); }
public bool IsProjectAssignedToUser(int projectId, int pfid, out ProjectMappingModel projectMapping) { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start."); try { using (ProjectDB projectDB = new ProjectDB()) { projectMapping = projectDB.GetProjectMappingByUser(projectId, pfid); } return(projectMapping != null); } catch (Exception exception) { errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace); throw; } finally { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end."); } }
public ProjectMappingModel GetProjectMappingByUser(int projectId, int pfid) { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start."); ProjectMappingModel projectMapping = null; try { OracleParameter[] objParams = { new OracleParameter("P_PROJECTID", projectId), new OracleParameter("P_PFID", pfid) }; DataTable dtRecords = new DataTable(); dtRecords = ReadRecord(objParams, "GET_PROJECT_MAP_BY_USER"); if (dtRecords.Rows.Count > 0) { projectMapping = new ProjectMappingModel(); projectMapping.Id = dtRecords.Rows[0]["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dtRecords.Rows[0]["ID"].ToString()); projectMapping.Pfid = dtRecords.Rows[0]["PFINDEXNO"] == DBNull.Value ? 0 : Convert.ToInt32(dtRecords.Rows[0]["PFINDEXNO"].ToString()); projectMapping.ProjectId = dtRecords.Rows[0]["PROJECTID"] == DBNull.Value ? 0 : Convert.ToInt32(dtRecords.Rows[0]["PROJECTID"].ToString()); projectMapping.IsProjectAdmin = dtRecords.Rows[0]["ISPROJECTADMIN"] == DBNull.Value ? 0 : Convert.ToInt32(dtRecords.Rows[0]["ISPROJECTADMIN"].ToString()); projectMapping.Project.Id = dtRecords.Rows[0]["PROJECTID"] == DBNull.Value ? 0 : Convert.ToInt32(dtRecords.Rows[0]["PROJECTID"].ToString()); projectMapping.Project.ProjectName = dtRecords.Rows[0]["PROJECTNAME"] == DBNull.Value ? "" : dtRecords.Rows[0]["PROJECTNAME"].ToString(); projectMapping.Project.Description = dtRecords.Rows[0]["PROJECTDESCRIPTION"] == DBNull.Value ? "" : dtRecords.Rows[0]["PROJECTDESCRIPTION"].ToString(); } } catch (Exception exception) { errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace); throw; } finally { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end."); } return(projectMapping); }
/// <summary> /// Adds mapping to project mapping table /// </summary> /// <param name="mappingModel">project mapping data</param> /// <returns>Database operation details</returns> public OperationDetails AddProjectMapping(ProjectMappingModel mappingModel) { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start."); OperationDetails operationDetails = null; try { using (UserDB userDB = new UserDB()) { operationDetails = userDB.AddProjectMapping(mappingModel); return(operationDetails); } } catch (Exception exception) { errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace); throw; } finally { log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end."); } }
public ActionResult AssignProject(AssignProjectViewModel model) { if (ModelState.IsValid) { ProjectMappingModel projectMapping = new ProjectMappingModel(); projectMapping.Pfid = model.Pfid; projectMapping.ProjectId = model.ProjectId; projectMapping.IsProjectAdmin = model.IsAdmin ? 1 : 0; projectMapping.CreatedBy = CurrentUser.Pfid; OperationDetails operationDetails = new UserBL().AddProjectMapping(projectMapping); if (operationDetails.OperationStatus == 1) { return(Json(new { success = true, message = "Project assigned successfully." }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = "Something went wrong!!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Validation Error." }, JsonRequestBehavior.AllowGet)); } }