コード例 #1
0
        private async Task <List <HandlerServiceResult> > ConfigureOperationDate(string answer, User user)
        {
            answer = answer.Trim();

            if (string.IsNullOrEmpty(answer))
            {
                return(new List <HandlerServiceResult> {
                    _resultService.BuildOperationInvalidDateErrorResult()
                });
            }

            DateTime date;

            if (answer.Equals("now"))
            {
                date = DateTime.Now;
            }
            else
            {
                var dayMonthYear = answer.Split('.');

                try
                {
                    date = new DateTime(int.Parse(dayMonthYear[2]), int.Parse(dayMonthYear[1]),
                                        int.Parse(dayMonthYear[0]));
                }
                catch (Exception)
                {
                    return(new List <HandlerServiceResult> {
                        _resultService.BuildOperationInvalidDateErrorResult()
                    });
                }
            }

            if (date > DateTime.Now)
            {
                return(new List <HandlerServiceResult>
                {
                    _resultService.BuildOperationInvalidDateErrorResult()
                });
            }

            var operation = await GetOrCreateOperationAsync(user);

            operation.Date       = date;
            operation.Configured = true;

            await _operationDocumentService.UpdateAsync(operation);

            user.Context = null;

            await _userDocumentService.UpdateAsync(user);

            return(new List <HandlerServiceResult> {
                _resultService.BuildFinishedConfiguringOperationResult()
            });
        }
コード例 #2
0
 public async Task UpdateOperationAsync(Operation operation)
 {
     await _operationDocumentService.UpdateAsync(operation);
 }