Exemplo n.º 1
0
        public TaskModel(Task task)
        {
            this.Id = task.Id;
            if (task.User != null)
            {
                this.UserId = task.User.Id;
                this.UserLoginName = task.User.LoginName;
            }

            this.Content = task.Content;
            this.Status = task.Status.ToString();
            this.Duration = task.Duration;
            this.CreateTime = task.CreateTime.ToJsonString();
        }
Exemplo n.º 2
0
 public static TaskModel From(Task task)
 {
     return new TaskModel(task);
 }
Exemplo n.º 3
0
        public ActionResult Create(string name, string content, int duration)
        {
            try
            {
                Task task = new Task();
                task.User = UserRepository.Get(name);

                if (task.User == null)
                {
                    return JsonError("用户状态异常");
                }

                task.Content = content;
                task.Duration = duration;//int.Parse(duration);
                task.Status = TaskStatus.发布中;
                task.CreateTime = DateTime.Now;

                task = TaskRepository.SaveOrUpdate(task);

                return JsonSuccess(TaskModel.From(task));
            }
            catch (Exception ex)
            {
                return JsonError(ex.Message);
            }
        }