Scorum
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
close_budget_by_advertising_moderator_evaluator.cpp
Go to the documentation of this file.
3 
8 
12 
13 namespace scorum {
14 namespace chain {
15 
17  data_service_factory_i& services)
18  : evaluator_impl<data_service_factory_i, close_budget_by_advertising_moderator_evaluator>(services)
19  , _account_service(services.account_service())
20  , _post_budget_service(services.post_budget_service())
21  , _banner_budget_service(services.banner_budget_service())
22  , _adv_property_service(services.advertising_property_service())
23 {
24 }
25 
28 {
29  switch (op.type)
30  {
31  case budget_type::post:
32  close_budget(_post_budget_service, op);
33  break;
34  case budget_type::banner:
35  close_budget(_banner_budget_service, op);
36  break;
37  }
38 }
39 
40 template <protocol::budget_type budget_type_v>
41 void close_budget_by_advertising_moderator_evaluator::close_budget(adv_budget_service_i<budget_type_v>& budget_svc,
42  const operation_type& op)
43 {
44  _account_service.check_account_existence(op.moderator);
45 
46  auto& current_moderator = _adv_property_service.get().moderator;
47  FC_ASSERT(current_moderator != SCORUM_MISSING_MODERATOR_ACCOUNT, "Advertising moderator was not set");
48  FC_ASSERT(current_moderator == op.moderator, "User ${1} is not the advertising moderator", ("1", op.moderator));
49  FC_ASSERT(budget_svc.is_exists(op.uuid), "Budget with id ${id} doesn't exist", ("id", op.uuid));
50 
51  budget_svc.finish_budget(op.uuid);
52 }
53 }
54 }
Definition: asset.cpp:15
virtual void check_account_existence(const account_name_type &, const optional< const char * > &context_type_name=optional< const char * >()) const =0
virtual bool is_exists(const uuid_type &uuid) const =0
virtual void finish_budget(const uuid_type &uuid)=0
virtual const object_type & get() const =0
Closes advertising budget by moderator, remaining funds will be returned to creator.