public TaskApplyModel(TaskApply taskApply) { this.Id = taskApply.Id; if (taskApply.Task != null) this.TaskId = taskApply.Task.Id; if (taskApply.User != null) { this.UserId = taskApply.User.Id; this.UserLoginName = taskApply.User.LoginName; } this.AuditReason = taskApply.AuditReason; this.AuditTime = taskApply.AuditTime.ToJsonString(); this.Status = taskApply.Status.ToString(); this.CreateTime = taskApply.CreateTime.ToJsonString(); }
public ActionResult Apply(string name, int taskid) { User user = UserRepository.Get(name); if (user == null) return JsonError("用户状态异常"); Task task = TaskRepository.Get(taskid); if (task == null) return JsonError("任务不存在"); TaskApply taskApply = new TaskApply(); taskApply.Task = task; taskApply.User = user; taskApply.Status = AuditStatus.等待审核; taskApply.CreateTime = DateTime.Now; taskApply = TaskApplyRepository.SaveOrUpdate(taskApply); return JsonSuccess(TaskApplyModel.From(taskApply)); }
public static TaskApplyModel From(TaskApply taskApply) { return new TaskApplyModel(taskApply); }