public async Task <Response> Create(OperationCreateModel model) { using (var uow = UnitOfWorkFactory.Create()) { var Operation = Mapper.Map <Operation>(model); if (model == null) { return new Response { Status = StatusEnum.Error, Message = "ничего на сервер не отправлено" } } ; if (!uow.OperationTypes.Check(model.OperationTypeId)) { return new Response { Status = StatusEnum.Error, Message = "Нет такого типа операций" } } ; await uow.Operations.CreateAsync(Operation); return(new Response { Status = StatusEnum.Accept, Message = "Запрос прошел успешно" }); } }
public async Task <OperationCreateModel> GetCreateModel() { using (var uow = UnitOfWorkFactory.Create()) { var Operation = new OperationCreateModel(); Operation.operationTypes = Mapper.Map <List <OperationTypeIndexModel> >(await uow.OperationTypes.GetAllAsync()); return(Operation); } }
public async Task <IActionResult> Create(OperationCreateModel op) { await this.operationService.CreateOperationAsync( op.OwnerID, op.GroupID, op.Amount, op.Description ); return(RedirectToAction("Details", "Group", new { Id = op.GroupID })); }
public async Task <IActionResult> Post(OperationCreateModel model) { if (model == null) { return(StatusCode(StatusCodes.Status500InternalServerError, new Response { Status = StatusEnum.Error, Message = "Ничего не оптравлено на сервер!" })); } var Result = await OperationService.Create(model); if (Result.Status == StatusEnum.Error) { return(StatusCode(StatusCodes.Status500InternalServerError, Result)); } return(Ok(Result)); }