public RequestApproved CloseRequest(RequestApproved request) { request = GetRequestApproved(request); if (request.IsReturned) { throw new Exception("Книга уже возвращена"); } var returnBook = Ninject.Get <UpdateBooksQuantityQuery>(); returnBook.Book = request.Id.Book; returnBook.BookQuantity = request.Id.BookQuantity; var closeRequest = Ninject.Get <CloseRequestQuery>(); closeRequest.RequestApproved = request; var executor = Ninject.Get <Executor>(); try { executor.ExecuteNonQueries(new NoValueQuery[] { returnBook, closeRequest }); request.IsReturned = true; } catch (Exception exc) { throw exc; } return(request); }
public RequestApproved CloseRequest(RequestApproved request) { request = GetRequestApproved(request); if (request.IsReturned) { throw new Exception("Книга уже возвращена"); } var returnBook = Ninject.Get<UpdateBooksQuantityQuery>(); returnBook.Book = request.Id.Book; returnBook.BookQuantity = request.Id.BookQuantity; var closeRequest = Ninject.Get<CloseRequestQuery>(); closeRequest.RequestApproved = request; var executor = Ninject.Get<Executor>(); try { executor.ExecuteNonQueries(new NoValueQuery[]{ returnBook, closeRequest }); request.IsReturned = true; } catch (Exception exc) { throw exc; } return request; }
//public IEnumerable<RequestApproved> GetApprovedRequests(RequestHeader request) { // var query = Ninject.Get<GetApprovedRequestsQuery>(); // query.Request = request; // return query.Execute(); //} //public IEnumerable<RequestRejected> GetRejectedRequests(RequestHeader request) { // var query = Ninject.Get<GetRejectedRequestsQuery>(); // query.Request = request; // return query.Execute(); //} public RequestApproved RenewRequest(RequestApproved request) { request = GetRequestApproved(request); if (request.IsReturned) { throw new Exception("Книга уже возвращена. Продление невозможно"); } if (DateTime.Now.Date <= request.ReturnDate.Date) { throw new Exception("Срок возврата еще не истек. Продление невозможно"); } var command = Ninject.Get <RenewRequestQuery>(); command.RequestApproved = request; try { command.Execute(); } catch (DbException exc) { throw new Exception("Достигнут предел числа продлений. Дальнейшее продление невозможно"); } return(request); }
public async Task ApproveRequest(int id) { var approved = new RequestApproved(id); await _getStore().WriteEvent(approved, Streams.UtoRequests); }
protected RequestApproved GetRequestApproved(RequestApproved source) { return GetApprovedRequests(source.Id.Id.Reader.Card).FirstOrDefault(s => s.Id.Equals(source.Id)); }
//public IEnumerable<RequestApproved> GetApprovedRequests(RequestHeader request) { // var query = Ninject.Get<GetApprovedRequestsQuery>(); // query.Request = request; // return query.Execute(); //} //public IEnumerable<RequestRejected> GetRejectedRequests(RequestHeader request) { // var query = Ninject.Get<GetRejectedRequestsQuery>(); // query.Request = request; // return query.Execute(); //} public RequestApproved RenewRequest(RequestApproved request) { request = GetRequestApproved(request); if (request.IsReturned) { throw new Exception("Книга уже возвращена. Продление невозможно"); } if (DateTime.Now.Date <= request.ReturnDate.Date) { throw new Exception("Срок возврата еще не истек. Продление невозможно"); } var command = Ninject.Get<RenewRequestQuery>(); command.RequestApproved = request; try { command.Execute(); } catch (DbException exc) { throw new Exception("Достигнут предел числа продлений. Дальнейшее продление невозможно"); } return request; }
protected RequestApproved GetRequestApproved(RequestApproved source) { return(GetApprovedRequests(source.Id.Id.Reader.Card).FirstOrDefault(s => s.Id.Equals(source.Id))); }
public RequestApproved CloseRequest(RequestApproved request) { return(ExecuteScoped(() => Channel.CloseRequest(request))); }
public RequestApproved RenewRequest(RequestApproved request) { return(ExecuteScoped(() => Channel.RenewRequest(request))); }
public RequestApprovedWrap(RequestApproved request) { Request = request; }
Task <RequestApproved> CloseRequest(RequestApproved request) { return(Task.Factory.StartNew(() => GetProxy().CloseRequest(request))); }
Task <RequestApproved> RenewalRequest(RequestApproved request) { return(Task.Factory.StartNew(() => GetProxy().RenewRequest(request))); }