Example #1
0
        public TaskResponseDto UpdateTask(UpdateTasksDto taskToBeUpdated)
        {
            _storage.UpdateTask(taskToBeUpdated);

            return(_storage.GetTasks(new TaskQuerySearch
            {
                Id = taskToBeUpdated.Id
            }).Single());
        }
Example #2
0
        public void UpdateTask(UpdateTasksDto taskToBeUpdated)
        {
            var existingTask = _context.Task
                               .Where(x => x.Id == taskToBeUpdated.Id)
                               .FirstOrDefault();

            if (taskToBeUpdated.Locked != null)
            {
                existingTask.Locked = (bool)taskToBeUpdated.Locked;
            }
            if (taskToBeUpdated.Name != null)
            {
                existingTask.Name = taskToBeUpdated.Name;
            }
            if (taskToBeUpdated.CompensationRate != null)
            {
                var compensationRates   = _context.CompensationRate.ToList().OrderByDescending(cr => cr.FromDate);
                var compRateToBeUpdated = compensationRates.First(cr => cr.TaskId == taskToBeUpdated.Id);
                compRateToBeUpdated.Value = (decimal)taskToBeUpdated.CompensationRate;
            }

            _context.SaveChanges();
        }
Example #3
0
 public bool GetFavorite(UpdateTasksDto taskToBeUpdated, int userId)
 {
     return(_context.TaskFavorites
            .FirstOrDefault(tf => tf.UserId == userId && tf.TaskId == taskToBeUpdated.Id) == null ? false : true);
 }