Skip to main content

Posts

Validate Incoming Value in MVC

Recent posts

Remove Duplicate Row in Sql Query

Method 1: -- Create Sample Table DECLARE @ table TABLE ( data VARCHAR ( 20 ) ) -- Insert Some Data INSERT INTO @ table VALUES ( 'not duplicate row' ) INSERT INTO @ table VALUES ( 'duplicate row' ) INSERT INTO @ table VALUES ( 'duplicate row' ) -- Find out Duplicate rows in table : SELECT   data , COUNT ( data ) nr FROM     @ table GROUP BY data HAVING   COUNT ( data ) > 1 -- Remove Duplicate rows from table SET NOCOUNT ON SET ROWCOUNT 1 WHILE 1 = 1    BEGIN       DELETE    FROM @ table       WHERE     data IN ( SELECT   data                                FROM     @ table                                GROUP BY data                                HAVING   COUNT ( * ) > 1 )       IF @ @ Rowcount = 0          BREAK ;    END SET ROWCOUNT 0 -- See Out put after remove duplicate record from table. SELECT  * FROM   @table

send push notification from C# using FCM

        public bool SendPushNotification(string deviceId, string message)         {      //applicationID = "AIzaSyxxxxxxxxxxxxxxxxxxx"     // senderId = "98xxxxxxxxx"             bool isSent = false;             string str = "";             try             {                 WebRequest tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send");                 tRequest.Method = "post";                 tRequest.ContentType = "application/json";                 var data = new                 {                     to = deviceId,                     notification = new                     {                         body = message,                         title = "SpAlert",                         sound = "Enabled"                     }                 };                 var serializer = new JavaScriptSerializer();                 var json = serializer.Serialize(data);            

Push Notifications in Xamarin Forms

Step by step guide: 1) In your shared project, create an Interface called IPushNotificationRegister public interface IPushNotificationRegister {     void ExtractTokenAndRegister(); } This interface is used for fetching the push token and then send it to the server. this Token is unique per device. 2) In Your shared proejct, you should invoke ExtractTokenAndRegister (using your favourite IOC, I called it right after login). Android Implementation: 3) Add Receivers for listening to events received by Google GCM service: a) [BroadcastReceiver] [IntentFilter(new[] { Intent.ActionBootCompleted })] public class GCMBootReceiver : BroadcastReceiver {     public override void OnReceive(Context context, Intent intent)     {         MyIntentService.RunIntentInService(context, intent);         SetResult(Result.Ok, null, null);     } } b) [assembly: Permission(Name = "@PACKAGE_NAME@.permission.C2D_MESSAGE")] [assembly: UsesPermission(Name = "android.permission.WAKE_LOCK")] [ass

Difference between Abstract Class and Interface with example in c#

1. Multiple inheritance  A class may inherit several interfaces.  class abc : ICrud,IDisposal  A class may inherit only one abstract class.  class abc : parentClass 2. Default implementation Interface : An interface cannot provide any code, just the signature. Example: interface IPerson     {         void Add(string name, string email);     }     Abstract class : An abstract class can provide complete, default code and/or just the details that have to be overridden. Example: abstract class APerson     {         //         string Name;         string Email;        // like interface        public abstract void Add(string name, string email);               public void Update()        {        }     } 3. Access Modifiers Interface : An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public     interface IPerson     {         void Add(string name, string email);     }     class iPerson :

Sql Helper into Xamarin Forms PCL Project

public abstract class SQLiteConnection : IDisposable { public string DatabasePath { get ; private set ; } public bool TimeExecution { get ; set ; } public bool Trace { get ; set ; } public SQLiteConnection ( string databasePath) { DatabasePath = databasePath; } public abstract int CreateTable < T > (); public abstract SQLiteCommand CreateCommand ( string cmdText, params object [] ps); public abstract int Execute ( string query, params object [] args); public abstract List < T > Query < T > ( string query, params object [] args) where T : new (); public abstract TableQuery < T > Table < T > () where T : new (); public abstract T Get < T > ( object pk) where T : new (); public bool IsInTransaction { get ; protected set ; } public abstract void BeginTransaction (); public abstract void Rollback (); public abstract void Co