public override void Process() { var contents = String.Empty; try { using (var stream = _request.InputStream) { using (var reader = new StreamReader(stream)) { contents = reader.ReadToEnd(); } } if (String.IsNullOrEmpty(contents)) { var customer = JsonConvert.DeserializeObject <Customer>(contents); _successor.Process(); } } catch (Exception ex) { Logger.Write("Something bad happened"); throw new BuisnessRulesException("RequestHandler", ex); } }
public override void Process() { var connectionString = ConfigurationManager.ConnectionStrings["database"].ConnectionString; using (var connection = new SqlConnection(connectionString)) { var commandText = "usp_verifyInvoince"; using (var command = new SqlCommand(commandText)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(_customer.Id); try { connection.Open(); var isInSystem = (bool)command.ExecuteScalar(); if (isInSystem) { _successor.Process(); } else { Logger.Write("Something Went Wrong"); } } catch (SqlException ex) { Logger.Write("Something Went Wrong"); throw new BuisnessRulesException("CustomerInSystemHandler", ex); } } } }
public override void Process() { try { using (var client = new WebClient()) { var uri = ConfigurationManager.AppSettings["WarehouseUri"]; foreach (var item in _order.LineItems) { var response = client.DownloadString(uri + item.Id); var inStock = JsonConvert.DeserializeObject <Boolean>(response); if (!inStock) { Logger.Write("Something bad happened"); } else { _successor.Process(); } } } } catch (WebException ex) { Logger.Write("Something bad happened"); throw new BuisnessRulesException("OrderItemsInStockHandler", ex); } }
public override void Process() { if (String.IsNullOrEmpty(_customer.FirstName)) { Logger.Write("Something Went Wrong"); } if (string.IsNullOrEmpty(_customer.LastName)) { Logger.Write("Something Went Wrong"); } _successor.Process(); }
public override void Process() { try { using (var client = new WebClient()) { var uri = ConfigurationManager.AppSettings["FullFillmentUri"]; var json = JsonConvert.SerializeObject(_customer); var response = client.UploadString(uri, json); _successor.Process(); } } catch (WebException ex) { Logger.Write("Something bad happened"); throw new BuisnessRulesException("HandleFullfillment", ex); } }
public override void Process() { var to = _customer.Email; var from = ConfigurationManager.AppSettings["fromAddress"]; var subject = String.Format("Your Order {0} From This Awesome Company Has Been Received", _customer.Order.Id); var body = "We'll let you know when the items have shipped"; var client = new SmtpClient(); try { client.Send(from, to, subject, body); _successor.Process(); } catch (System.Net.Mail.SmtpException ex) { Logger.Write("Something bad happened"); throw new BuisnessRulesException("SendEmailConfirmationHandler", ex); } }
public override void Process() { try { var attachmentPoint = Int32.Parse(ConfigurationManager.AppSettings["AttachmentPoint"]); var totalBill = _customer.Order.LineItems.Sum(i => i.BilledAmount + i.Tax); if (totalBill > attachmentPoint && _customer.IsPreferred) { foreach (var item in _customer.Order.LineItems) { item.Discount = item.BilledAmount * .95; } } _successor.Process(); } catch (ConfigurationException ex) { Logger.Write("Something bad happened"); throw new BuisnessRulesException("ApplyOrderDiscountHandler", ex); } }