// DELETE /api/applications/5
        public HttpResponseMessage Delete(string id)
        {
            DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx);

            Guid apiKey;

            Guid.TryParse(id, out apiKey);

            if(apiKey == null)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled Exception Deleting Application.  ApiKey could not be parsed as a GUID. {0}", id));

                var message = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                message.ReasonPhrase = "Invalid ApiKey.  Cannot be parsed to GUID.";

                return message;
            }

            try
            {
                applicationService.DeleteApplication(apiKey);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled Exception Deleting Application. {0}", ex.Message));

                return new HttpResponseMessage(HttpStatusCode.InternalServerError);
            }

            return new HttpResponseMessage(HttpStatusCode.OK);
        }
        // DELETE /api/applications/5
        public HttpResponseMessage Delete(string id)
        {
            DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx);

            Guid apiKey;

            Guid.TryParse(id, out apiKey);

            if (apiKey == null)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled Exception Deleting Application.  ApiKey could not be parsed as a GUID. {0}", id));

                var message = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                message.ReasonPhrase = "Invalid ApiKey.  Cannot be parsed to GUID.";

                return(message);
            }

            try
            {
                applicationService.DeleteApplication(apiKey);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled Exception Deleting Application. {0}", ex.Message));

                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
 public RegistrationWorkflow()
 {
     emailService = new DomainServices.EmailService(_ctx);
     applicationServices = new DomainServices.ApplicationService();
     smsLogServices = new SMSLogService(_ctx);
     smsService = new DomainServices.SMSService(applicationServices, smsLogServices, _ctx, logger);
     transactionBatchService = new DomainServices.TransactionBatchService(_ctx, logger);
 }
Пример #4
0
 public RegistrationWorkflow()
 {
     emailService            = new DomainServices.EmailService(_ctx);
     applicationServices     = new DomainServices.ApplicationService();
     smsLogServices          = new SMSLogService(_ctx);
     smsService              = new DomainServices.SMSService(applicationServices, smsLogServices, _ctx, logger);
     transactionBatchService = new DomainServices.TransactionBatchService(_ctx, logger);
 }
Пример #5
0
 public MessageWorkflow(IDbContext context)
 {
     _ctx = new Context();
     _transactionBatchService = new TransactionBatchService(_ctx, _logger);
     _emailService            = new DomainServices.EmailService(_ctx);
     _applicationService      = new ApplicationService(_ctx);
     _smsLogService           = new SMSLogService(_ctx);
     _smsService = new DomainServices.SMSService(_applicationService, _smsLogService, _ctx, _logger);
 }
 public PaymentAccountWorkflow(IDbContext context)
 {
     _ctx = context;
     _transactionBatchService = new TransactionBatchService(_ctx, _logger);
     _emailService = new DomainServices.EmailService(_ctx);
     _applicationService = new ApplicationService(_ctx);
     _smsLogService = new SMSLogService(_ctx);
     _smsService = new DomainServices.SMSService(_applicationService, _smsLogService, _ctx, _logger);
 }
Пример #7
0
 public PaymentAccountWorkflow(IDbContext context)
 {
     _ctx = context;
     _transactionBatchService = new TransactionBatchService(_ctx, _logger);
     _emailService            = new DomainServices.EmailService(_ctx);
     _applicationService      = new ApplicationService(_ctx);
     _smsLogService           = new SMSLogService(_ctx);
     _smsService = new DomainServices.SMSService(_applicationService, _smsLogService, _ctx, _logger);
 }
Пример #8
0
 public MessageWorkflow(IDbContext context)
 {
     _ctx = new Context();
     _transactionBatchService = new TransactionBatchService(_ctx, _logger);
     _emailService = new DomainServices.EmailService(_ctx);
     _applicationService = new ApplicationService(_ctx);
     _smsLogService = new SMSLogService(_ctx);
     _smsService = new DomainServices.SMSService(_applicationService, _smsLogService, _ctx, _logger);
 }
Пример #9
0
 public UserWorkflow(IDbContext context)
 {
     _ctx                    = context;
     logger                  = LogManager.GetCurrentClassLogger();
     emailService            = new DomainServices.EmailService(_ctx);
     applicationServices     = new DomainServices.ApplicationService();
     smsLogServices          = new SMSLogService(_ctx);
     smsService              = new DomainServices.SMSService(applicationServices, smsLogServices, _ctx, logger);
     transactionBatchService = new DomainServices.TransactionBatchService(_ctx, logger);
 }
Пример #10
0
 public MessageWorkflow(DomainServices.ApplicationService applicationServices, DomainServices.EmailService emailService,
     DomainServices.TransactionBatchService transactionBatchService, DomainServices.SMSLogService smsLogService,
     DomainServices.SMSService smsService)
 {
     _transactionBatchService = transactionBatchService;
     _emailService = emailService;
     _applicationService = applicationServices;
     _smsLogService = smsLogService;
     _smsService = smsService;
 }
Пример #11
0
 public MessageWorkflow(DomainServices.ApplicationService applicationServices, DomainServices.EmailService emailService,
                        DomainServices.TransactionBatchService transactionBatchService, DomainServices.SMSLogService smsLogService,
                        DomainServices.SMSService smsService)
 {
     _transactionBatchService = transactionBatchService;
     _emailService            = emailService;
     _applicationService      = applicationServices;
     _smsLogService           = smsLogService;
     _smsService = smsService;
 }
Пример #12
0
 public UserWorkflow(IDbContext context)
 {
     _ctx = context;
     logger = LogManager.GetCurrentClassLogger();
     emailService = new DomainServices.EmailService(_ctx);
     applicationServices = new DomainServices.ApplicationService();
     smsLogServices = new SMSLogService(_ctx);
     smsService = new DomainServices.SMSService(applicationServices, smsLogServices, _ctx, logger);
     transactionBatchService = new DomainServices.TransactionBatchService(_ctx, logger);
 }
        // PUT /api/applications/5
        public HttpResponseMessage Put(String id, ApplicationModels.UpdateApplicationRequest request)
        {
            DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx);

            Guid apiKey;

            Guid.TryParse(id, out apiKey);

            if (apiKey == null)
            {
                _logger.Log(LogLevel.Error, String.Format("Exception Updating Application.  ApiKey {0} could not be parsed as a GUID.", id));

                var message = new HttpResponseMessage(HttpStatusCode.BadRequest);
                message.ReasonPhrase = "Invalid ApiKey.  Cannot be parsed to GUID.";

                return(message);
            }

            Application application = null;

            try
            {
                application = applicationService.GetApplication(id);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled Exception Deleting Application.  Application with the API Key {0} not found. {0}", id, ex.Message));

                var message = new HttpResponseMessage(HttpStatusCode.NotFound);
                message.ReasonPhrase = "Application Resource Not Found.";

                return(message);
            }


            try
            {
                application.IsActive        = request.isActive;
                application.ApplicationName = request.name;
                application.Url             = request.url;

                applicationService.UpdateApplication(application);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled Exception updating application {0}. {1}", id, ex.Message));

                var message = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                message.ReasonPhrase = ex.Message;

                return(message);
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
 public PaymentAccountWorkflow(DomainServices.ApplicationService applicationServices, DomainServices.Interfaces.IEmailService emailService,
     DomainServices.TransactionBatchService transactionBatchService, DomainServices.SMSLogService smsLogService,
     DomainServices.SMSService smsService)
 {
     _ctx = new Context();
     _transactionBatchService = transactionBatchService;
     _emailService = emailService;
     _applicationService = applicationServices;
     _smsLogService = smsLogService;
     _smsService = smsService;
 }
Пример #15
0
 public PaymentAccountWorkflow(DomainServices.ApplicationService applicationServices, DomainServices.Interfaces.IEmailService emailService,
                               DomainServices.TransactionBatchService transactionBatchService, DomainServices.SMSLogService smsLogService,
                               DomainServices.SMSService smsService)
 {
     _ctx = new Context();
     _transactionBatchService = transactionBatchService;
     _emailService            = emailService;
     _applicationService      = applicationServices;
     _smsLogService           = smsLogService;
     _smsService = smsService;
 }
        // GET /api/applications/5
        public HttpResponseMessage <ApplicationModels.ApplicationResponse> Get(String id)
        {
            DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx);

            Guid apiKey;

            Guid.TryParse(id, out apiKey);

            if (apiKey == null)
            {
                _logger.Log(LogLevel.Error, String.Format("Unable to parse Guid {0}", id));

                return(new HttpResponseMessage <ApplicationModels.ApplicationResponse>(HttpStatusCode.BadRequest));
            }

            Application application;

            try
            {
                application = applicationService.GetApplication(apiKey.ToString());
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled exception getting application {0}. {1}", id, ex.Message));

                var response = new HttpResponseMessage <ApplicationModels.ApplicationResponse>(HttpStatusCode.InternalServerError);
                response.ReasonPhrase = ex.Message;

                return(response);
            }

            if (application == null)
            {
                var response = new HttpResponseMessage <ApplicationModels.ApplicationResponse>(HttpStatusCode.BadRequest);
                response.ReasonPhrase = "Invalid Application";

                return(response);
            }

            //TODO: check to make sure passed in id is the calling application

            return(new HttpResponseMessage <ApplicationModels.ApplicationResponse>(new ApplicationModels.ApplicationResponse()
            {
                apiKey = application.ApiKey.ToString(),
                id = application.ApiKey.ToString(),
                isActive = application.IsActive,
                url = application.Url
            }, HttpStatusCode.OK));
        }
        // GET /api/applications/5
        public HttpResponseMessage<ApplicationModels.ApplicationResponse> Get(String id)
        {
            DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx);

            Guid apiKey;

            Guid.TryParse(id, out apiKey);

            if (apiKey == null)
            {
                _logger.Log(LogLevel.Error, String.Format("Unable to parse Guid {0}", id));

                return new HttpResponseMessage<ApplicationModels.ApplicationResponse>(HttpStatusCode.BadRequest);
            }

            Application application;

            try
            {
                application = applicationService.GetApplication(apiKey.ToString());
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled exception getting application {0}. {1}", id, ex.Message));

                var response = new HttpResponseMessage<ApplicationModels.ApplicationResponse>(HttpStatusCode.InternalServerError);
                response.ReasonPhrase = ex.Message;

                return response;
            }

            if (application == null)
            {
                var response = new HttpResponseMessage<ApplicationModels.ApplicationResponse>(HttpStatusCode.BadRequest);
                response.ReasonPhrase = "Invalid Application";

                return response;
            }

            //TODO: check to make sure passed in id is the calling application

            return new HttpResponseMessage<ApplicationModels.ApplicationResponse>(new ApplicationModels.ApplicationResponse()
            {
                apiKey = application.ApiKey.ToString(),
                id = application.ApiKey.ToString(),
                isActive = application.IsActive,
                url = application.Url
            }, HttpStatusCode.OK);
        }
Пример #18
0
        static void Main(string[] args)
        {
            Context _ctx   = new Context();
            Logger  logger = LogManager.GetCurrentClassLogger();

            DomainServices.ApplicationService applicationServices = new DomainServices.ApplicationService();
            DomainServices.SMSLogService      smsLogService       = new DomainServices.SMSLogService(_ctx);
            DomainServices.SMSService         smsService          = new DomainServices.SMSService(applicationServices, smsLogService, _ctx, logger);

            try
            {
                smsService.SendSMS(Guid.Parse("BDA11D91-7ADE-4DA1-855D-24ADFE39D174"), "2892100266", "0BE0EFAA-13F1-4830-9547-CF1203A681C1");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        // POST /api/applications
        public HttpResponseMessage Post(ApplicationModels.SubmitApplicationRequest request)
        {
            DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx);
            Domain.Application application;

            try
            {
                application = applicationService.AddApplication(request.name, request.url, request.isActive);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled exception adding application. {0}", ex.Message));

                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
Пример #20
0
        static void Main(string[] args)
        {
            Context _ctx = new Context();
            Logger logger = LogManager.GetCurrentClassLogger();

            DomainServices.ApplicationService applicationServices = new DomainServices.ApplicationService();
            DomainServices.SMSLogService smsLogService = new DomainServices.SMSLogService(_ctx);
            DomainServices.SMSService smsService = new DomainServices.SMSService(applicationServices, smsLogService, _ctx, logger);

            try
            {
                smsService.SendSMS(Guid.Parse("BDA11D91-7ADE-4DA1-855D-24ADFE39D174"), "2892100266", "0BE0EFAA-13F1-4830-9547-CF1203A681C1");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        // POST /api/applications
        public HttpResponseMessage Post(ApplicationModels.SubmitApplicationRequest request)
        {
            DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx);
            Domain.Application application;

            try
            {
                application = applicationService.AddApplication(request.name, request.url, request.isActive);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled exception adding application. {0}", ex.Message));

                return new HttpResponseMessage(HttpStatusCode.InternalServerError);
            }

            return new HttpResponseMessage(HttpStatusCode.Created);
        }
        // PUT /api/applications/5
        public HttpResponseMessage Put(String id, ApplicationModels.UpdateApplicationRequest request)
        {
            DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx);

            Guid apiKey;

            Guid.TryParse(id, out apiKey);

            if(apiKey == null)
            {
                _logger.Log(LogLevel.Error, String.Format("Exception Updating Application.  ApiKey {0} could not be parsed as a GUID.", id));

                var message = new HttpResponseMessage(HttpStatusCode.BadRequest);
                message.ReasonPhrase = "Invalid ApiKey.  Cannot be parsed to GUID.";

                return message;
            }

            Application application = null;

            try
            {
                application = applicationService.GetApplication(id);
            }
            catch(Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled Exception Deleting Application.  Application with the API Key {0} not found. {0}", id, ex.Message));

                var message = new HttpResponseMessage(HttpStatusCode.NotFound);
                message.ReasonPhrase = "Application Resource Not Found.";

                return message;
            }

            try
            {
                application.IsActive = request.isActive;
                application.ApplicationName = request.name;
                application.Url = request.url;

                applicationService.UpdateApplication(application);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, String.Format("Unhandled Exception updating application {0}. {1}", id, ex.Message));

                var message = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                message.ReasonPhrase = ex.Message;

                return message;
            }

            return new HttpResponseMessage(HttpStatusCode.OK);
        }