public async Task <T> CreateAsync(T value, string createdBy, bool save = true)
        {
            T result = _commandRepository.Create(value, createdBy);
            await _commandRepository.SaveAsync();

            return(result);
        }
예제 #2
0
        public async Task <CreateCommandResponse> Post(CreateCommandRequest request)
        {
            if (!await batchRepository.DoesBatchExist(request.BatchId))
            {
                throw Err.BatchNotFound(request.BatchId);
            }

            var step = await stepRepository.Get(request.BatchId, request.StepName);

            if (step == null)
            {
                throw Err.StepNotFound(request.StepName);
            }

            if (await commandRepository.DoesCommandExist(request.BatchId, request.StepName, request.CommandName))
            {
                throw Err.CommandAlreadyExists(request.CommandName);
            }

            var command = request.ConvertTo <Core.Entities.Command>();

            command.StepId = step.Id;

            await commandRepository.Create(command);

            return(new CreateCommandResponse());
        }
 public IActionResult Create([Bind("Id,Name,Quantity,Price,IsCredit,OperationTime")] Stock stock)
 {
     if (ModelState.IsValid)
     {
         stock.Id = Guid.NewGuid();
         _stockCommandRepository.Create(stock);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(stock));
 }
 public IActionResult Create([Bind("Id,Name,Description")] Product product)
 {
     if (ModelState.IsValid)
     {
         product.Id = Guid.NewGuid();
         _productsCommandRepository.Create(product);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(product));
 }
        public async Task <Student> Handle(CreateStudentCommand request, CancellationToken cancellationToken)
        {
            var student = new Student(request.FirstName,
                                      request.LastName,
                                      request.Email,
                                      request.Phones,
                                      request.Address);

            repository.Create(student);
            await repository.UnitOfWork.SaveChangesAsync();

            return(student);
        }
예제 #6
0
        protected override async void HandleMessage(string content)
        {
            var command = JsonConvert.DeserializeObject <Command>(content);

            command.Id = await _commandRepository.GetNextId();

            await _commandRepository.Create(command);

            Console.WriteLine("new command: " + command.Id + " " + command.Code + " " + command.DateTime.ToString() + " " + command.RecordId + " " + command.Status);

            await command.Execute();



            // SignalR obrada...
            _ = _hub.Clients.All.SendAsync("commands", command);
        }