public async Task <JsonResult> AddStageToPipeLine(AddStageViewModel model) { if (!ModelState.IsValid) { return(JsonModelStateErrors()); } return(await JsonAsync(_service.AddStageToPipeLineAsync(model))); }
public AddStageDialog() { InitializeComponent(); if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) { _viewModel = App.Container.Get <AddStageViewModel>(); this.DataContext = _viewModel; } }
/// <summary> /// Add stage to pipeline /// </summary> /// <param name="model"></param> /// <returns></returns> public virtual async Task <ResultModel <Guid> > AddStageToPipeLineAsync(AddStageViewModel model) { if (model == null) { return(InvalidParametersResultModel <Guid> .Instance); } var stageBd = await _context.Stages.FirstOrDefaultAsync(x => x.PipeLineId == model.PipeLineId && string.Equals(x.Name.Trim(), model.Name.Trim(), StringComparison.CurrentCultureIgnoreCase)); if (stageBd != null) { return new ResultModel <Guid> { IsSuccess = false, Errors = new List <IErrorModel> { new ErrorModel { Message = "Stage [" + model.Name + "] exist" } } } } ; var pipeLineRequest = await GetPipeLineByIdAsync(model.PipeLineId); if (!pipeLineRequest.IsSuccess) { return new ResultModel <Guid> { IsSuccess = false, Errors = new List <IErrorModel> { new ErrorModel { Message = " select pipeLine does not exist" } } } } ; var stage = new Stage { Name = model.Name, Term = model.Term, PipeLineId = model.PipeLineId, Order = await GetPipeLineStagesCountAsync(model.PipeLineId), WorkFlowStateId = model.WorkFlowStateId, IsSystem = model.IsSystem }; await _context.Stages.AddAsync(stage); var result = await _context.PushAsync(); if (!result.IsSuccess) { return(result.Map(stage.Id)); } await SystemOrderStage(stage.PipeLineId); if (result.IsSuccess) { await _notify.SendNotificationAsync(new Notification { Content = $"Add stage {stage?.Name} in the {pipeLineRequest.Result?.Name}", Subject = "Info", NotificationTypeId = NotificationType.Info }); } return(result.Map(stage.Id)); }
public AddStageDialog() { InitializeComponent(); _viewModel = App.Container.Get <AddStageViewModel>(); this.DataContext = _viewModel; }