Tuesday, February 27, 2018

Publishing the API on Azure

Introduction:

Publish the web application on azure from Visual studio.

Steps:

  1. Publish your web application using visual studio. It gives this  error. but It creates App Service Plan and App Service in Azure.
  2.  sign in to portal.azure.com
  3. Select the App Service which you have created.
  4. Click on Get Publish Profile.
  5. Now Again Go to Visual studio and Publish.
  6. This time while publishing select Import.
  7. Select the file which you have downloaded from azure.
  8. Click Ok.
  9. Click On Publish.
  10. Your Application will get Publish.

Monday, February 12, 2018

Get the index of an item in a list in C#

int index = myList.FindIndex(a => a.Prop == oProp);
If you don't want to use LINQ, then:
int index;
for (int i = 0; i < myList.Count; i++)
{
    if (myList[i].Prop == oProp)
    {
       index = i;
       break;
    }
}

Sunday, February 11, 2018

Validate Date in C#

DateTime dt;
if (DateTime.TryParseExact(str, "M/d/yyyy", null, DateTimeStyles.None, out dt) == true)
{
//your date is valid and is in dt
}

Tuesday, February 6, 2018

List Stored Procedure Modified and Created in Last N Days


If stored procedure was created but never modified afterwards modified date and create date for that stored procedure are same.

SELECT 
nameFROM sys.objectsWHERE type 'P'AND DATEDIFF(D,modify_dateGETDATE()) < 10
----Change 7 to any other day value
Following script will provide name of all the stored procedure which were created in last 7 days, they may or may not be modified after that.
SELECT nameFROM sys.objectsWHERE type 'P'AND DATEDIFF(D,create_dateGETDATE()) < 10
----Change 7 to any other day value.