public async Task <BalanceDTO> UpdateBalance(BalanceDTO newBalance) { Balance balanceToSave = new Balance() { CurrentBalance = JsonDocument.Parse(newBalance.Balance), SubmitedDate = newBalance.SubmitedDate }; DateTime currentDate = newBalance.SubmitedDate; Position latestPosition = await _unitOfWork.Positions.GetLatestPosition(); if (latestPosition.SubmitedDate.Year == currentDate.Year && latestPosition.SubmitedDate.Month == currentDate.Month && latestPosition.SubmitedDate.Day == currentDate.Day) { balanceToSave.Position = latestPosition; _unitOfWork.Balances.Add(balanceToSave); _unitOfWork.SaveChanges(); return(newBalance); } else { Position newPosition = new Position() { SubmitedDate = currentDate, }; _positionService.AddNewPosition(newPosition); balanceToSave.Position = await _unitOfWork.Positions.GetLatestPosition(); _unitOfWork.Balances.Add(balanceToSave); _unitOfWork.SaveChanges(); return(newBalance); } }
private async Task <AdaptiveCard> OpenNewPosition(Activity activity, CancellationToken cancellationToken) { var commandData = JsonConvert.DeserializeObject <PositionCreateCommand>(activity.Value?.ToString()); if (commandData is null) { return(null); } var position = await _positionService.AddNewPosition(commandData, cancellationToken); return(_mapper.Map <AdaptiveCard>(position)); }
public async Task <IActionResult> AddNewPosition([FromBody] Position position) { var result = _validator.Validate(position); if (!result.IsValid) { return(BadRequest(result)); } await _positionService.AddNewPosition(position); return(Created($"/EmployeePosition/{position.Id}", position)); }
private async Task <InvokeResponse> CreateConfirmJobPostingTaskModuleResponse(ITurnContext turnContext, PositionCreateCommand positionCreateCommand, CancellationToken cancellationToken) { var position = await _positionService.AddNewPosition(positionCreateCommand, cancellationToken); positionCreateCommand.CommandId = AppCommands.ConfirmCreationOfNewPosition; positionCreateCommand.PositionId = position.PositionId; var positionsTemplate = new PositionTemplateModel { Items = new List <Position> { position }, ButtonActions = new List <AdaptiveAction> { new AdaptiveSubmitAction { Title = "Confirm posting", Data = positionCreateCommand }, new AdaptiveSubmitAction { Title = "Cancel" } } }; var messageActivity = await _positionsTemplate.RenderTemplate(turnContext, null, TemplateConstants.PositionAsAdaptiveCardWithMultipleItems, positionsTemplate); var actionResponse = new MessagingExtensionActionResponse { Task = new TaskModuleContinueResponse { Type = "continue", Value = new TaskModuleTaskInfo { Card = messageActivity.Attachments.First(), Title = "Confirm new posting", Width = "medium", Height = "medium" } } }; return(_mapper.Map <MessagingExtensionActionResponse, InvokeResponse>(actionResponse)); }
private async Task <TaskModuleResponseEnvelope> CreateConfirmJobPostingTaskModuleResponse(PositionCreateCommand positionCreateCommand, CancellationToken cancellationToken) { var position = await _positionService.AddNewPosition(positionCreateCommand, cancellationToken); positionCreateCommand.CommandId = AppCommands.ConfirmCreationOfNewPosition; positionCreateCommand.PositionId = position.PositionId; var card = _mapper.Map <AdaptiveCard>(position); card.Actions = new List <AdaptiveAction> { new AdaptiveSubmitAction { Title = "Confirm posting", Data = positionCreateCommand }, new AdaptiveSubmitAction { Title = "Cancel" } }; return(new TaskModuleResponseEnvelope { Task = new TaskModuleContinueResponse { Type = "continue", Value = new TaskModuleTaskInfo { Card = card.ToAttachment(), Title = "Confirm new posting", Width = "medium", Height = "medium" } } }); }
public async Task <IMessageActivity> OpenPositionAsync( ITurnContext turnContext, CancellationToken cancellationToken) { var commandData = JsonConvert.DeserializeObject <PositionCreateCommand>(turnContext.Activity.Value?.ToString()); if (commandData is null) { return(null); } var position = await _positionService.AddNewPosition(commandData, cancellationToken); var positionsTemplate = new PositionTemplateModel { Items = new List <Position> { position } }; var messageActivity = await _positionsTemplate.RenderTemplate(turnContext, null, TemplateConstants.PositionAsAdaptiveCardWithMultipleItems, positionsTemplate); return(messageActivity); }