示例#1
0
        public IActionResult Edit(TimeTaskEditViewModel model)
        {
            TimeTask timeTask = _mapper.Map <TimeTask>(model);

            BackgroundJob.Delete(timeTask.BackgroundJobId);
            string backgroundJobId = BackgroundJob.Schedule(() => ExecuteTimeTask(timeTask), timeTask.TimeStamp);

            timeTask.BackgroundJobId = backgroundJobId;

            _timeTaskRepository.EditTimeTask(timeTask);
            _timeTaskRepository.Savechanges();

            return(RedirectToAction("Index", "TimeTask", new { id = model.SocketId }));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id)
        {
            TimeTask timeTask = _timeTaskRepository.GetTimeTaskById(id);

            if (timeTask == null)
            {
                return(new NotFoundResult());
            }

            AuthorizationResult authorizationResult = await _authorizationService
                                                      .AuthorizeAsync(User, timeTask, Operations.Update);

            if (!authorizationResult.Succeeded)
            {
                return(new ForbidResult());
            }

            TimeTaskEditViewModel timeTaskViewModel = _mapper.Map <TimeTaskEditViewModel>(timeTask);

            return(View(timeTaskViewModel));
        }