Esempio n. 1
0
 public TaskCard(TaskCardViewModel form)
 {
     TaskId = form.TaskId;
     DeadLine = form.Deadline;
     EisenHowerType = form.EisenHowerType;
     Card = new Card
     {
         Content = form.Content,
         AssetType = AssetType.Time,
         PullValue = form.AssetValue,
         PushValue = form.FailValue,
         ValueUnit = form.ValueUnit,
         Status = CardStatus.NotStarted,
         Tag = form.Tag
     };
 }
Esempio n. 2
0
        public async Task<ActionResult> Edit(TaskCardViewModel form)
        {
            string partialHtml;
            if (ModelState.IsValid)
            {
                try
                {
                    var userId = User.Identity.GetUserId<int>();
                    var taskCard = new TaskCard(form)
                    {
                        UserId = userId,
                        ModifiedBy = User.Identity.Name,
                        ModifiedOn = DateTime.Now
                    };
                    await TaskRepository.EditTaskCardAsync(taskCard);
                    partialHtml = RenderViewHelper.RenderRazorViewToString(ControllerContext, "_TaskCard", taskCard);
                    return Json(new
                    {
                        Status = ResponseStatus.Success,
                        Data = partialHtml,
                        TaskId = taskCard.TaskId,
                        TargetId = GetDisplayTargetId(taskCard.EisenHowerType)

                    });
                }
                catch (Exception ex)
                {
                    //todo use elma to log ex
                    ModelState.AddModelError("Exception", "Hi Boss, System is sick. Need MC!");
                }
            }
            partialHtml = RenderViewHelper.RenderRazorViewToString(ControllerContext,"_TaskCardEditForm", form);
            return Json(new
            {
                Status = ResponseStatus.Fail,
                Data = partialHtml
            });
        }