public void UpdateCityCountry(CountryCityModel obj) { try { //using (var dc = new shortenURLEntities()) //{ // dc.SHORTURLDATAs.Where(x => x.PK_Shorturl == obj.pk_shorturl_id).Update(y => new SHORTURLDATA { //City = obj.City, Region = obj.Region, Country = obj.Country, CountryCode = obj.CountryCode, PostalCode = obj.PostalCode, //Latitude = obj.latitude, Longitude = obj.longitude, MetroCode = obj.metro_code, FK_City_Master_id = obj.fk_city_master_id }); //} var shorturl_record = dc.SHORTURLDATAs.SingleOrDefault(x => x.PK_Shorturl == obj.pk_shorturl_id); if (shorturl_record != null) { var uaParser = Parser.GetDefault(); ClientInfo c = uaParser.Parse(obj.userAgent); if (c != null) { shorturl_record.DeviceName = c.Device.Model; shorturl_record.DeviceBrand = c.Device.Brand; shorturl_record.OS_Name = c.OS.Family; shorturl_record.OS_Version = c.OS.Major; } shorturl_record.City = obj.City; shorturl_record.Region = obj.Region; shorturl_record.Country = obj.Country; shorturl_record.CountryCode = obj.CountryCode; shorturl_record.PostalCode = obj.PostalCode; shorturl_record.City_Latitude = obj.latitude; shorturl_record.City_Longitude = obj.longitude; shorturl_record.MetroCode = obj.metro_code; shorturl_record.FK_City_Master_id = obj.fk_city_master_id; dc.SaveChanges(); } } catch (AggregateException e) { } }
public void UpdateRowid(long?rowid) { using (var dc = new shortenURLEntities()) { var res = dc.tmp_rownum_update.SingleOrDefault(x => x.PK_RowUpdate_ID == 1); if (res != null) { res.row_update = rowid; dc.SaveChanges(); } // dc.tmp_rownum_update.Where(x => x.PK_RowUpdate_ID == 1).Update(y => new tmp_rownum_update { row_update = rowid }); } }
public static void LogErrorData(string stackTraceInfo, string message) { try { shortenURLEntities dc = new shortenURLEntities(); ErrorLog objErrorLog = new ErrorLog(); objErrorLog.StackTrace = stackTraceInfo; objErrorLog.ErrorMessage = message; objErrorLog.DateCreated = System.DateTime.Now; dc.ErrorLogs.Add(objErrorLog); dc.SaveChanges(); string err = ""; err = "Error Occured on:" + DateTime.Now.ToString() + "<br>"; err += "Message: " + message; err += "Stack Trace:<br>" + stackTraceInfo; //EmailUtil.SendMail("*****@*****.**", ConfigurationManager.AppSettings["Error Mail"].ToString(), "", "", "Error ShortenURL", " <br>Message : " + err); } catch (Exception ex) { } }