Ejemplo n.º 1
0
        /// <summary>
        /// Load history detail
        /// </summary>
        /// <param name="historyId"></param>
        /// <returns></returns>
        public async Task <ResultModel <TaskHistoryModel> > LoadHistoryDetail(int historyId)
        {
            ResultModel <TaskHistoryModel> result = new ResultModel <TaskHistoryModel>();

            TaskHistory data = await UnitOfWork.TaskHistoryRepository.Entity
                               .Include(c => c.Task).AsNoTracking()
                               .FirstOrDefaultAsync(c => c.Id == historyId);

            result.Data = data.ToModel();

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Save history
        /// </summary>
        /// <returns></returns>
        public async Task <ResultModel <TaskHistoryModel> > SaveHistory(int taskId, string title, string updateInfo, int accountId)
        {
            ResultModel <TaskHistoryModel> result = new ResultModel <TaskHistoryModel>();

            TaskHistoryModel model = new TaskHistoryModel
            {
                Content = updateInfo,
                Task    = new TaskItemModel {
                    TaskId = taskId
                },
                User = new AccountModel {
                    AccountId = accountId
                },
                Title       = title,
                UpdatedDate = DateTime.Now
            };

            TaskHistory entity = model.ToEntity();

            if (entity.Id <= 0)
            {
                entity.UpdatedDate = DateTime.Now;
            }

            entity.Task = null;
            entity.User = null;

            UnitOfWork.TaskHistoryRepository.Add(entity);

            int iResult = await UnitOfWork.CommitAsync();

            if (iResult > 0)
            {
                result.Status = ActionStatus.Ok;
                result.Data   = entity.ToModel();
            }

            return(result);
        }