Esempio n. 1
0
 public async Task AddTaskCardAsync(TaskCard taskCard)
 {
     using (var db = new ApplicationDbContext())
     {
         db.Set<TaskCard>().Add(taskCard);
         await db.SaveChangesAsync();
     }
 }
Esempio n. 2
0
 public async Task<TaskCard> EditTaskCardAsync(TaskCard taskCard)
 {
     using (var db = new ApplicationDbContext())
     {
         db.Set<TaskCard>().AddOrUpdate(taskCard);
         await db.SaveChangesAsync();
         return taskCard;
     }
 }
Esempio n. 3
0
 public static string GetTaskCardData(this HtmlHelper helper, TaskCard taskCard)
 {
     return string.Format(@"data-id='{0}' data-assettype={1} data-valueunit={2} 
                          data-assetvalue={3} data-failvalue={4} data-tag={5} 
                          data-content='{6}' data-tasktype={7} data-deadline={8}", 
                          taskCard.TaskId, taskCard.Card.AssetType, taskCard.Card.ValueUnit,
                         taskCard.Card.PullValue,taskCard.Card.PushValue, taskCard.Card.Tag,
                         taskCard.Card.Content, (int)taskCard.EisenHowerType, DateTimeDisplay(helper,taskCard.DeadLine));
 }
Esempio n. 4
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
            });
        }
Esempio n. 5
0
 private async Task UpdateAsset(TaskCard taskCard, IIdentity identity)
 {
     var userId = identity.GetUserId<int>();
     var isPull = taskCard.IsPull();
     var card = taskCard.Card;
     var asset = new Asset
     {
         AssetType = card.AssetType,
         AssetPurpose = isPull ? AssetPurpose.Pull : AssetPurpose.Push,
         AssetValue = isPull ? card.PullValue : card.PushValue,
         UserId = userId,
         ModifiedBy = identity.Name,
         ModifiedOn = DateTime.Now,
         Date = DateTime.Today,
         DayOfWeek = (int) DateTime.Today.DayOfWeek
     };
     await AssetRepository.UpdateAssetAsync(asset);
 }