private static void UpdateCurrentLocation(CurrentLocation currentLocation, IDataLayer dataLayer)
 {
     dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
     dataLayer.Sql = "update CurrentLocation set lat = @lat, long = @long where deviceid = @deviceid";
     dataLayer.AddParameter("@deviceId", currentLocation.DeviceID);
     dataLayer.AddParameter("@lat", currentLocation.Lat);
     dataLayer.AddParameter("@long", currentLocation.Long);
     dataLayer.ExecuteNonQuery();
 }
 private static void InsertCurrentLocation(CurrentLocation currentLocation, IDataLayer dataLayer)
 {
     dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
     dataLayer.Sql = "insert into CurrentLocation values(@deviceId, @lat, @long)";
     dataLayer.AddParameter("@deviceId", currentLocation.DeviceID);
     dataLayer.AddParameter("@lat", currentLocation.Lat);
     dataLayer.AddParameter("@long", currentLocation.Long);
     dataLayer.ExecuteNonQuery();
 }
 private static void UpdateUpdateActivity(Activity activity, IDataLayer dataLayer)
 {
     dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
     dataLayer.Sql = "update Activity set what = @what, [when] = @when, lat = @lat, long = @long where deviceid = @deviceid";
     dataLayer.AddParameter("@deviceId", activity.DeviceID);
     dataLayer.AddParameter("@What", activity.What);
     dataLayer.AddParameter("@when", activity.When);
     dataLayer.AddParameter("@lat", activity.Lat);
     dataLayer.AddParameter("@long", activity.Long);
     dataLayer.ExecuteNonQuery();
 }
Beispiel #4
0
 private static bool IsProfileFound(string deviceId, IDataLayer dataLayer)
 {
     dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
     dataLayer.Sql = "select count(*) from Profile where deviceid = @deviceid";
     dataLayer.AddParameter("@deviceid", deviceId);
     return((int)dataLayer.ExecuteScalar() > 0);
 }
Beispiel #5
0
 private static void SavePicture(string deviceId, string filePath, IDataLayer dataLayer)
 {
     dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
     dataLayer.Sql = string.Format("update activity set image = (select * from openrowset(BULK N'{0}', SINGLE_BLOB) AS CategoryImage) where deviceid =  @deviceid", filePath);
     dataLayer.AddParameter("@deviceid", deviceId);
     dataLayer.ExecuteNonQuery();
 }
Beispiel #6
0
        private static Profile GetProfile(string deviceId, IDataLayer dataLayer)
        {
            Profile profile = null;

            try
            {
                dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
                dataLayer.Sql = "select * from profile where deviceid = @deviceid";
                dataLayer.AddParameter("@deviceid", deviceId);
                DataTable dataTable = dataLayer.ExecuteDataTable();
                if (dataTable != null && dataTable.Rows != null && dataTable.Rows.Count == 1)
                {
                    profile = new Profile()
                    {
                        DeviceID    = (string)dataTable.Rows[0]["deviceid"],
                        UserName    = (string)dataTable.Rows[0]["username"],
                        ProfileName = (string)dataTable.Rows[0]["profilename"],
                        Hobies      = (string)dataTable.Rows[0]["hobies"],
                        About       = (string)dataTable.Rows[0]["about"],
                        //Rating = (byte)dataTable.Rows[0]["rating"],
                        //Reviews = (long)dataTable.Rows[0]["reviews"],
                        //views = (long)dataTable.Rows[0]["views"]
                    };
                }
                else if (dataTable.Rows.Count > 1)
                {
                    //return new HttpError("More than one profile found");
                }
            }catch (Exception ex)
            {
                //throw ex;
            }
            return(profile);
        }
 private static bool IsDeviceFound(CurrentLocation currentLocation, IDataLayer dataLayer)
 {
     dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
     dataLayer.Sql = "select count(*) from CurrentLocation where deviceid = @deviceid";
     dataLayer.AddParameter("@deviceid", currentLocation.DeviceID);
     return((int)dataLayer.ExecuteScalar() > 0);
 }
 private static void InsertActivity(Activity activity, IDataLayer dataLayer)
 {
     dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
     dataLayer.Sql = "insert into Activity values(@deviceId, @what, @when, @lat, @long, null, @description, @id)";
     dataLayer.AddParameter("@deviceId", activity.DeviceID);
     dataLayer.AddParameter("@What", activity.What);
     dataLayer.AddParameter("@when", activity.When);
     dataLayer.AddParameter("@lat", activity.Lat);
     dataLayer.AddParameter("@long", activity.Long);
     dataLayer.AddParameter("@description", activity.description);
     dataLayer.AddParameter("@id", Guid.NewGuid());
     dataLayer.ExecuteNonQuery();
 }
Beispiel #9
0
 private static void UpdateProfile(Profile profile, IDataLayer dataLayer)
 {
     try
     {
         dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
         dataLayer.Sql = "update Profile set username = @username, profilename = @profilename, hobies = @hobies, about = @about, rating = @rating, reviews = @reviews, views = @reviews where deviceid = @deviceid";
         dataLayer.AddParameter("@deviceid", profile.DeviceID);
         dataLayer.AddParameter("@username", profile.UserName);
         dataLayer.AddParameter("@profilename", profile.ProfileName);
         dataLayer.AddParameter("@hobies", profile.Hobies);
         dataLayer.AddParameter("@about", profile.About);
         dataLayer.AddParameter("@rating", profile.Rating);
         dataLayer.AddParameter("@reviews", profile.Reviews);
         dataLayer.AddParameter("@views", profile.views);
         dataLayer.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #10
0
 private static void InsertProfile(Profile profile, IDataLayer dataLayer)
 {
     try
     {
         dataLayer.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
         dataLayer.Sql = "insert into Profile (deviceid, username, profilename, hobies, about, rating, reviews, views) values(@deviceId, @username, @profilename, @hobies, @about, @rating, @reviews, @views)";
         dataLayer.AddParameter("@deviceId", profile.DeviceID);
         dataLayer.AddParameter("@username", profile.UserName);
         //dataLayer.AddParameter("@profilephoto", profile.ProfilePhoto);
         dataLayer.AddParameter("@profilename", profile.ProfileName);
         dataLayer.AddParameter("@hobies", profile.Hobies);
         dataLayer.AddParameter("@about", profile.About);
         dataLayer.AddParameter("@rating", profile.Rating);
         dataLayer.AddParameter("@reviews", profile.Reviews);
         dataLayer.AddParameter("@views", profile.views);
         dataLayer.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }