/// <summary>
        /// Update stage
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task <ResultModel> UpdateStageAsync(UpdateStageViewModel model)
        {
            if (model == null)
            {
                return(new InvalidParametersResultModel());
            }
            var stageRequest = await FindStageByIdAsync(model.Id);

            if (!stageRequest.IsSuccess)
            {
                return(stageRequest.ToBase());
            }
            var stage = stageRequest.Result;

            stage.Name = model.Name;
            stage.Term = model.Term;

            _context.Stages.Update(stage);
            var result = await _context.PushAsync();

            if (result.IsSuccess)
            {
                await _notify.SendNotificationAsync(new Notification
                {
                    Content            = $"Update stage {stage?.Name} in the {stage?.PipeLine?.Name}",
                    Subject            = "Info",
                    NotificationTypeId = NotificationType.Info
                });
            }

            return(result);
        }
Exemple #2
0
 public async Task <JsonResult> UpdateStage([Required] UpdateStageViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(JsonModelStateErrors());
     }
     return(await JsonAsync(_service.UpdateStageAsync(model)));
 }
Exemple #3
0
        public async Task <IActionResult> UpdateStageAsync([FromBody] UpdateStageViewModel updateStageViewModel)
        {
            var updateStageDTO = _mapper.Map <UpdateStageDTO>(updateStageViewModel);

            var stageDTO = await _stageService.UpdateStageAsync(updateStageDTO);

            var stageViewModel = _mapper.Map <StageViewModel>(stageDTO);

            return(Ok(stageViewModel));
        }
Exemple #4
0
        public IActionResult Put(int id, [FromBody] UpdateStageViewModel updateStageViewModel)
        {
            return(ApiAction(() =>
            {
                var contract = _mapper.Map <UpdateStageContract>(updateStageViewModel);
                contract.Id = id;

                _processStageService.Update(contract);

                return Accepted();
            }));
        }