public static void RemoveTaskByID(MyDataModel db, int taskID) { T_TASK taskForDelete = GetTaskByID(db, taskID); db.T_TASK.Remove(taskForDelete); db.SaveChanges(); }
public bool ModifyTaskState(int taskID, int teamID, int state, string currentUserMail) { var currentUserRepoModel = this._userRepository.GetUser(currentUserMail); if (currentUserRepoModel == null) { Enforce.Throw(new LogicErrorException("当前用户已被删除")); } T_TASK task = _taskBll.GetEntity(new DapperExQuery <T_TASK>() .AndWhere(s => s.ID, OperationMethod.Equal, taskID)); if (task == null) { Enforce.Throw(new LogicErrorException("当前任务不存在")); } //TeamRepoModel teamRepoModel = _teamRepository.GetTeamDetail(teamID); //if (!teamRepoModel.members.Any(A => A.memberMail == currentUserMail)) //{ // Enforce.Throw(new LogicErrorException("该用户不属于当前团队")); //} TaskInfoModel taskInfoModel = Mapper.Map <T_TASK, TaskInfoModel>(task); taskInfoModel.state = state; return(_taskBll.ModifyTask(AutoMapper.Mapper.Map <TaskInfoModel, T_TASK>(taskInfoModel), currentUserRepoModel.info.userName, currentUserMail, DateTime.Now)); }
protected void btnSave_Click(object sender, EventArgs e) { MyDataModel context = new MyDataModel(); int goalID; if (!int.TryParse(Request.QueryString["GoalID"], out goalID)) { lblGoalName.Text = Messages.goalName + Messages.errorMissingGoalID; lblGoalName.ForeColor = Color.Red; return; } string taskName = tbxTaskName.Text; if (string.IsNullOrEmpty(taskName)) { taskName = "noname"; } string description = tbxDescription.Text; bool isDone = bool.Parse(dlstDone.SelectedItem.Value); T_GOAL goal = T_GOALservice.GetGoalByID(context, goalID); if (goal == null) { lblGoalName.Text = Messages.goalName + Messages.errorIncorrectGoalID; lblGoalName.ForeColor = Color.Red; return; } int taskID; //create(if TaskID absent) or update task if (int.TryParse(Request.QueryString["TaskID"], out taskID)) { if (!T_TASKservice.IsTaskExists(context, taskID)) { return; } T_TASK task = T_TASKservice.GetTaskByID(context, taskID); task.GoalID = goalID; task.TaskName = taskName; task.Description = description; task.Done = isDone; task.UpdateDate = DateTime.Now; } else { T_TASK newTask = new T_TASK { GoalID = goalID, TaskName = taskName, Description = description, Done = isDone, UpdateDate = DateTime.Now, T_GOAL = goal }; context.T_TASK.Add(newTask); } context.SaveChanges(); Response.Redirect("~/_GoalPage.aspx?GoalID=" + goalID); }
public bool ModifyTask(int taskId, int projectID, int teamID, string title, string content, string assignedEmail, string typeName, int time, int state, string currentUserMail) { assignedEmail = string.IsNullOrEmpty(assignedEmail) ? assignedEmail : assignedEmail.ToLower(); var currentUserRepoModel = this._userRepository.GetUser(currentUserMail); if (currentUserRepoModel == null) { Enforce.Throw(new LogicErrorException("当前用户已被删除")); } string assignedUserName = null; if (assignedEmail != null) { var assignedUserRepoModel = this._userRepository.GetUser(assignedEmail); if (assignedUserRepoModel == null) { Enforce.Throw(new LogicErrorException("指派的用户已被删除")); } assignedUserName = assignedUserRepoModel.info.userName; } T_TASK task = _taskBll.GetEntity(new DapperExQuery <T_TASK>() .AndWhere(s => s.ID, OperationMethod.Equal, taskId)); if (task == null) { Enforce.Throw(new LogicErrorException("当前任务不存在")); } //TeamRepoModel teamRepoModel = _teamRepository.GetTeamDetail(teamID); //if (!teamRepoModel.members.Any(A => A.memberMail == currentUserMail)) //{ // Enforce.Throw(new LogicErrorException("该用户不属于当前团队")); //} if (projectID > 0) { ProjectRepoModel projectRepoModel = _projectRepository.GetProjectDetail(projectID); if (!projectRepoModel.members.Any(A => A.memberMail == assignedEmail)) { Enforce.Throw(new LogicErrorException("该用户不属于当前项目")); } } TaskInfoModel taskInfoModel = Mapper.Map <T_TASK, TaskInfoModel>(task); taskInfoModel.title = title != null ? title : taskInfoModel.title; taskInfoModel.content = content != null ? content : taskInfoModel.content; taskInfoModel.assignedName = assignedEmail != null ? assignedUserName : taskInfoModel.assignedName; taskInfoModel.assignedEmail = assignedEmail != null ? assignedEmail : taskInfoModel.assignedEmail; taskInfoModel.typeName = typeName != null ? typeName : taskInfoModel.typeName; taskInfoModel.time = time != 0 ? time : taskInfoModel.time; taskInfoModel.state = state; return(_taskBll.ModifyTask(AutoMapper.Mapper.Map <TaskInfoModel, T_TASK>(taskInfoModel), currentUserRepoModel.info.userName, currentUserMail, DateTime.Now)); }
public void AddTask(TaskEntity task) { var newTask = new T_TASK(); newTask.TASK_NM = task.TaskName; newTask.PARENT_TASK_ID = task.ParentId; newTask.PRIORITY = task.Priority; newTask.STRT_DT = Utility.GetFormattedDate(task.StartDate).Value; newTask.END_DT = Utility.GetFormattedDate(task.EndDate).Value; newTask.PROJ_ID = task.ProjectId; newTask.USR_ID = task.UserId; newTask.STATUS = "A"; // New tasks are Active by default _db.T_TASK.Add(newTask); _db.SaveChanges(); }
public TaskRepoModel getTaskInfo(int taskID) { TaskRepoModel taskRepoModel = new TaskRepoModel(); T_TASK task = _taskBll.GetEntity(new DapperExQuery <T_TASK>() .AndWhere(s => s.ID, OperationMethod.Equal, taskID)); if (task == null) { Enforce.Throw(new LogicErrorException("当前任务不存在")); } TaskInfoModel taskInfoModel = Mapper.Map <T_TASK, TaskInfoModel>(task); taskRepoModel.info = taskInfoModel; taskRepoModel.logs = this.getTaskLog(taskID); return(taskRepoModel); }
public bool ModifyTask(T_TASK task, String userName, String createUserMail, DateTime createTime) { bool isSucess = true; using (var tran = DbContext.DbTransaction) { try { DbContext.Update(task); var taskLog = new T_TASK_LOG(); taskLog.T_TASK_ID = task.ID; taskLog.T_STATE = task.T_STATE; taskLog.T_TITLE = task.T_TITLE; taskLog.T_CONENT = task.T_CONENT; taskLog.T_ASSIGNED_NAME = task.T_ASSIGNED_NAME; taskLog.T_ASSIGNED_EMAIL = task.T_ASSIGNED_EMAIL; taskLog.T_TYPE_NAME = task.T_TYPE_NAME; taskLog.T_TIME = task.T_TIME; taskLog.CREATE_USER_NAME = userName; taskLog.CREATE_USER_MAIL = createUserMail; taskLog.CREATE_TIME = createTime; DbContext.Insert(taskLog); } catch (Exception e) { isSucess = false; throw e; } finally { if (isSucess) { tran.Commit(); } else { tran.Rollback(); } } return(isSucess); } }
public int CreateTask(T_TASK task, String userName) { int taskId = 0; using (var tran = DbContext.DbTransaction) { try { DbContext.Insert(task); var taskLog = new T_TASK_LOG(); taskLog.T_TASK_ID = task.ID; taskLog.T_STATE = task.T_STATE; taskLog.T_TITLE = task.T_TITLE; taskLog.T_CONENT = task.T_CONENT; taskLog.T_ASSIGNED_NAME = task.T_ASSIGNED_NAME; taskLog.T_ASSIGNED_EMAIL = task.T_ASSIGNED_EMAIL; taskLog.T_TYPE_NAME = task.T_TYPE_NAME; taskLog.T_TIME = task.T_TIME; taskLog.CREATE_USER_NAME = userName; taskLog.CREATE_USER_MAIL = task.CREATE_USER_MAIL; taskLog.CREATE_TIME = task.CREATE_TIME; DbContext.Insert(taskLog); taskId = task.ID; } catch (Exception e) { throw e; } finally { if (taskId > 0) { tran.Commit(); } else { tran.Rollback(); } } return(taskId); } }
protected void btnBack_Click(object sender, EventArgs e) { MyDataModel context = new MyDataModel(); int goalID = int.Parse(lblHiddenGoalID.Text.Trim()); IQueryable <T_TASK> tasks = T_TASKservice.GetTasksByGoalID(context, goalID); T_TASK isFalseDone = T_TASKservice.GetIncompliteTasks(tasks, false).FirstOrDefault(); //created goal have null tasks and t.Done always null T_GOAL currentGoal = T_GOALservice.GetGoalByID(context, goalID); if (currentGoal != null) { if (isFalseDone != null || tasks.Count() == 0) { currentGoal.Done = false; } else { currentGoal.Done = true; } context.SaveChanges(); } Response.Redirect("~/_GoalsPage.aspx"); }
protected void Page_Load(object sender, EventArgs e) { MyDataModel context = new MyDataModel(); int tasknameMaxLength = 50; int descriptionMaxLength = 50; Label1.Text = tbxDescription.Text.Length.ToString(); tbxDescription.Attributes.Add("MaxLength", tbxDescription.MaxLength.ToString()); string actualUserName = Page.User.Identity.Name; int goalID; if (!int.TryParse(Request.QueryString["GoalID"], out goalID)) { tbxTaskName.MaxLength = tasknameMaxLength; tbxTaskName.ToolTip = string.Format("Max {0} characters", tasknameMaxLength); tbxDescription.ToolTip = string.Format("Max {0} characters", descriptionMaxLength); lblGoalName.Text = Messages.goalName + Messages.errorMissingGoalID; lblGoalName.ForeColor = Color.Red; return; } else { T_GOAL goalAbsentOrDeleted = T_GOALservice.GetGoalByID(context, goalID); if (goalAbsentOrDeleted == null) { BadGoalID(Messages.goalName + " is absent!"); return; } else if (goalAbsentOrDeleted.T_ACCOUNT.Email != actualUserName) { BadGoalID(Messages.goalName + " is incorrect!"); return; } else { lblGoalName.ForeColor = Color.Empty; btnSave.Enabled = true; lblGoalName.Text = Messages.goalName + goalAbsentOrDeleted.GoalName; } } if (!IsPostBack) { int taskID; if (int.TryParse(Request.QueryString["TaskID"], out taskID)) { if (!T_TASKservice.IsTaskExists(context, taskID)) { return; } T_TASK task = T_TASKservice.GetTaskByID(context, taskID); tbxTaskName.Text = task.TaskName; tbxDescription.Text = task.Description; Label1.Text = task.Description.Count().ToString(); dlstDone.SelectedValue = task.Done.ToString().ToLower(); } else { Label1.Text = tbxDescription.Text.Length.ToString(); } } }