Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C# 7 and .NET Core 2.0 Blueprints

You're reading from   C# 7 and .NET Core 2.0 Blueprints Build effective applications that meet modern software requirements

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher
ISBN-13 9781788396196
Length 428 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Dirk Strauss Dirk Strauss
Author Profile Icon Dirk Strauss
Dirk Strauss
Jas Rademeyer Jas Rademeyer
Author Profile Icon Jas Rademeyer
Jas Rademeyer
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. eBook Manager and Catalogue App 2. Cricket Score Calculator and Tracker FREE CHAPTER 3. Cross Platform .NET Core System Info Manager 4. Task Bug Logging ASP .NET Core MVC App 5. ASP.NET SignalR Chat Application 6. Web Research Tool with Entity Framework Core 7. A Serverless Email Validation Azure Function 8. Twitter Clone Using OAuth 9. Using Docker and ASP.NET Core 10. Other Books You May Enjoy

Modifying the Azure Function code


While this is all quite exciting (it should be, this is really cool tech), we need to make a few changes to the Azure Function to meet our requirements:

  1. Identify the return statement in your Azure Function. It will look as follows:
      return name == null 
        ? req.CreateResponse(HttpStatusCode.BadRequest,
         "Please pass a name on the query string or in the request 
          body") 
        : req.CreateResponse(HttpStatusCode.OK, "Hello " + name); 

Let's simplify the code a bit and just return true if the email address is not empty. Replace the return statement with the following code:

      if (email == null) 
      { 
        return req.CreateResponse(HttpStatusCode.BadRequest,
         "Please pass an email address on the query string or
          in the request body"); 
      } 
      else 
      { 
        bool blnValidEmail = false; 
        if (email.Length > 0) 
        { 
            blnValidEmail = true; 
        } 
 
        return...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image