Exemplo n.º 1
0
        public string SayHello()
        {
            //// 1) instantiating a vendor object ONLY when this method is called
            //var vendor = new Vendor();
            //vendor.SendWelcomeEmail("Message from Product");

            var emailService = new EmailService();
            var confirmation = emailService.SendMessage
                               (
                "New Product",
                this.ProductName,
                "*****@*****.**"
                               );

            // var result = LogAction("saying hello");


            return("Hello, your "
                   + ProductName
                   + " with Product number: '"
                   + ProductID
                   + "' is a "
                   + ProductDescription
                   + " available on: "
                   + AvailabilityDate?.ToShortDateString());
        }
Exemplo n.º 2
0
        public string SayHello()
        {
            //var vendor = new Vendor();
            //vendor.SendWelcomeEmail("This is the new email message");

            var emailService = new EmailService();
            var confirmation = emailService.SendMessage("New product", this.ProductName, "*****@*****.**");

            var result = LoggingService.LogAction("Hello hello from logging");

            return($"Hello {ProductName} ({ProductID}): {Description} Available on:{AvailabilityDate?.ToShortDateString()}");
        }
Exemplo n.º 3
0
        public string SayHello()
        {
            //var vendor = new Vendor();
            //vendor.SendWelcomeEmail("Message from Product");

            var emailService = new EmailService();
            var confirmation = emailService.SendMessage("New Product", this.ProductName, "*****@*****.**");

            var result = LoggingService.LogAction("Saying hello");

            return("Hello " + ProductName + " (" + productId + "): " + Description + " Available on:"
                   + AvailabilityDate?.ToShortDateString());
        }
Exemplo n.º 4
0
        public string SayHello()
        {
            vendor.SendWelcomeEmail("Message from Product");

            var emailservice = new EmailService();

            emailservice.SendMessage("New Product", this.Name, "*****@*****.**");

            var loggingService = LogAction("Saying hello");

            return($"Hello {Name} ({Id}): {Description}. " +
                   $"Available on: {AvailabilityDate?.ToShortDateString()}");
        }
Exemplo n.º 5
0
        public string SayHello()
        {
            // only good, when only needed in this method
            //var vendor = new Vendor();
            //vendor.SendWelcomeEmail("Message from Product");

            var emailService = new EmailService();
            var confirmation = emailService.SendMessage("New Product",
                                                        this.ProductName, "*****@*****.**");
            var result = LogAction("Email sent");

            return("Hello " + ProductName + " " + ProductDescription + " " + ProductId
                   + " Available on: " + AvailabilityDate?.ToShortDateString());
        }
Exemplo n.º 6
0
        public string SayHello()
        {
            //var vendor = new Vendor();
            var emailService = new EmailService();

            string confirmation;
            string result;

            //vendor.SendWelcomeEmail("Message from Product");
            confirmation = emailService.SendMessage("New Product", this.ProductName, "*****@*****.**");
            result       = LogAction("saying hello");

            return($"Hello {ProductName} ({ProductId}): {Description} Available on: {AvailabilityDate?.ToShortDateString()}");
        }
Exemplo n.º 7
0
        /// <summary>
        /// Basic Methode to test the class
        /// </summary>
        /// <returns></returns>
        public string SayHello()
        {
            //when a instance is only needded once, instantiate the instanstance in the methode
            var vendor = new Vendor();

            vendor.SendWelcomeEmail("Message from Acme.com");
            var emailService = new EmailService();
            var confirmation = emailService.SendMessage("New Product", this.ProductName, "*****@*****.**");

            var result = LogAction("The result is logged");

            return("Hello " + ProductName +
                   " (" + ProductId + "): " + ProductDescription +
                   ", Available on: " + AvailabilityDate?.ToShortDateString());
        }
Exemplo n.º 8
0
        public string SayHello()
        {
            //var vendor = new Vendor();
            //vendor.SendWelcomeEmail("Message from Product");

            var emailService = new EmailService();
            var confirmation = emailService.SendMessage("New Product",
                                                        this.ProductName,
                                                        "*****@*****.**");

            //static classes can not be instantiated (only use for method access)
            var result = LoggingService.LogAction(confirmation);

            return($"Hello {ProductName} ({ProductId}): {Description}" +
                   $" Available on: {AvailabilityDate?.ToShortDateString()}");
        }
Exemplo n.º 9
0
        this.Cost + (this.Cost * markupPercent / 100);                       // removed the {}'s added the => (lambda operator)

        // removed the return keyword before the this.Cost


        // ***** Original Method before refactoring using Expression-Bodied Method from C# 6 *****
        //public decimal CalculateSuggestedPrice(decimal markupPercent)       //******************
        //{                                                                   //******************
        //    return this.Cost + (this.Cost * markupPercent / 100);           //******************
        //}                                                                   //******************
        //****************************************************************************************

        public string SayHello()
        {
            // **** This object only needed here so is only instantiated in the method that needs it ****
            //var vendor = new Vendor();    // Commented out for always needed for always needed related object
            //vendor.SendWelcomeEmail("Message from Product");  //Commented out for always needed related object
            // **** Object created only here because only needed in this one method ****

            var emailService = new EmailService();
            var confirmation = emailService.SendMessage("New Product", this.ProductName, "*****@*****.**");

            var result = LogAction("saying hello");

            return("Hello " + ProductName + " (" +
                   ProductId + "): " + Description +
                   " Available on: " + AvailabilityDate?.ToShortDateString());
        }
Exemplo n.º 10
0
        public string SayHello()
        {
            //var vendor = new Vendor();
            //vendor.SendWelcomeEmail("Message from product");

            var emailService = new EmailService();
            var confirmation = emailService.SendMessage("New Product", this.productName, "*****@*****.**");

            var result = LogAction("saying hello");

            return("Hello " + ProductName +
                   " (" + ProductId + "): " +
                   Description +
                   " Available on: " +
                   //If not null, use datestring
                   AvailabilityDate?.ToShortDateString());
        }
Exemplo n.º 11
0
        public string SayHello()
        {
            //Vendor vendor = new Vendor();
            //vendor.SendWelcomeEmail("Message from Poduct Class");


            EmailService emailservice = new EmailService();

            emailservice.SendMessage("New Product", this.ProductName, "*****@*****.**");
            var result = LogAction("Say Hello");

            return("Hello " +
                   ProductName +
                   "(" + ProductId + "): " +
                   Description +
                   " Available on: " +
                   AvailabilityDate?.ToShortDateString());
        }
Exemplo n.º 12
0
        public string SayHello()
        {
            // can call because the vendor class is in the same namespace
            // as this class

            // instatiating the vendor only needed in the class within this method
            //var vendor = new Vendor();
            //vendor.SendWelcomeEmail("Message from product");

            var emailService = new EmailService();
            var confirmation = emailService.SendMessage("Subject", this.ProductName, "*****@*****.**");

            // using static feature to call static method
            var result = LogAction("saying hello method in Product");

            return("Hello " + ProductName +
                   " (" + ProductId + "): " + Description +
                   " Available on: " +
                   AvailabilityDate?.ToShortDateString());
        }
Exemplo n.º 13
0
        public string productCode => $"{this.Category}-{this.sequencenumber:0000}";  //String interpolation replaces above code -C# 6

        public string SayHelloTest()
        {
            var vendor = new Vendor();

            vendor.SendWelcomeEmail("welcome to the email");

            var emailservice = new EmailService();


            emailservice.SendMessage("test message", this.productName, "*****@*****.**");

            //c# 6 , we can import statis classes, using static Acme.Common.LoggingService;
            var result = LoggingService.LogAction("Say hello");

            return("This is a test for PropertyID " + PropertyId.ToString() + "Product Avaialble on" + AvailabilityDate?.ToShortDateString());
        }
Exemplo n.º 14
0
 public string SayHello()
 {
     //var vendor = new Vendor();
     //vendor.SendWelcomeEmail("Message from Product");
     return("Hello " + ProductName + " (" + ProductId + "): " + Description + " " + ProductVendor.CompanyName + " Available on: " + AvailabilityDate?.ToShortDateString());
 }