public bool IsDivOrStateCodeExisInOterRow(long id, string code) { try { OiiOHaatDCDataContext dbContext = DatabaseHelper.GetDataModelDataContext(); List <DivisionOrState> divisionOrStateList = new List <DivisionOrState>(); //divisionOrStateList = dbContext.DivisionOrStates.Where(d => d.IsRemoved == false && d.Code == code && d.IID != id).ToList(); divisionOrStateList = dbContext.DivisionOrStates.Where(d => d.Code == code && d.IID != id).ToList(); dbContext.Dispose(); if (divisionOrStateList.Count > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public bool IsDivisionOrStateCodeExists(string code, int countryID) { try { OiiOHaatDCDataContext dbContext = DatabaseHelper.GetDataModelDataContext(); List <DivisionOrState> divisionOrStateList = new List <DivisionOrState>(); //divisionOrStateList = dbContext.DivisionOrStates.Where(d => d.IsRemoved == false && d.Code.Contains(code) && d.CountryID==countryID).ToList(); divisionOrStateList = dbContext.DivisionOrStates.Where(d => d.CountryID == countryID && d.Code.Contains(code)).ToList(); dbContext.Dispose(); if (divisionOrStateList.Count > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public bool IsCountryCodeExistOtherRows(int id, string code) { try { OiiOHaatDCDataContext dbContext = DatabaseHelper.GetDataModelDataContext(); List <Country> countryCodeList = new List <Country>(); //countryCodeList = dbContext.Countries.Where(c => c.IsRemoved == false && c.Code.Contains(code) && c.IID !=id).ToList(); countryCodeList = dbContext.Countries.Where(c => c.Code == code && c.IID != id).ToList(); dbContext.Dispose(); if (countryCodeList.Count > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public string GetRatingByIID(Int64 ratingIID) { try { //DataTable dt = this.GetData("SELECT ISNULL(AVG(Rating), 0) AverageRating, COUNT(Rating) RatingCount FROM UserRatings"); Int64 locID = 0; string fullstatus = null; OiiOHaatDCDataContext dbContext = DatabaseHelper.GetDataModelDataContext(); //var rating = dbContext.UserRatings.FirstOrDefault(x => x.IID == ratingIID); //var location = dbContext.SP_GetLocationForGoogleMap(locID).SingleOrDefault(); //fullstatus = location.CurrentLocation + ',' + location.PoliceStationName + ',' + location.DistrictName + ',' + location.DivisionOrStateName + ',' + location.CountryName; dbContext.Dispose(); return(fullstatus); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public bool IsParentCategoryID(Int64 CatID) { try { OiiOHaatDCDataContext dbContext = DatabaseHelper.GetDataModelDataContext(); List <Category> categoryList = new List <Category>(); categoryList = dbContext.Categories.Where(d => d.IsRemoved == false && d.IID == CatID && d.ParentID == null).ToList(); dbContext.Dispose(); if (categoryList.Count > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public void UpdateCategory(Category category) { try { OiiOHaatDCDataContext msDC = DatabaseHelper.GetDataModelDataContext(); Category categoryNew = msDC.Categories.Single(d => d.IID == category.IID); count = 0; CountCounter(categoryNew.ParentID); count = count - subCatCounter; string msg = "- "; string newSpaceMsg = string.Empty; //space for subcategory for (int spaceCount = 0; spaceCount < count; spaceCount++) { newSpaceMsg = msg + newSpaceMsg; } category.Description = newSpaceMsg + category.Name; DatabaseHelper.Update <Category>(msDC, category, categoryNew); msDC.Dispose(); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public string GetLocationByIID(Int64 locationIID) { try { Int64 locID = 0; string fulladdress = null; OiiOHaatDCDataContext dbContext = DatabaseHelper.GetDataModelDataContext(); var material = dbContext.Materials.FirstOrDefault(x => x.IID == locationIID); if (material != null) { locID = material.LocationID; } var location = dbContext.SP_GetLocationForGoogleMap(locID).SingleOrDefault(); fulladdress = location.CurrentLocation + ',' + location.PoliceStationName + ',' + location.DistrictName + ',' + location.DivisionOrStateName + ',' + location.CountryName; dbContext.Dispose(); return(fulladdress); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public void CountCounter(Int64?parId) { try { if (parId != null) { if (count > 25) { throw new Exception(("Error at parent category Id" + parId)); } OiiOHaatDCDataContext dbContext = DatabaseHelper.GetDataModelDataContext(); var parentId = dbContext.SP_CategoryTree_GetCategoryParentID(parId).ToList().Single().ParentID; dbContext.Dispose(); //var parent = dbContext.Categories.SingleOrDefault(parIid => parIid.IID == parId); count++; CountCounter(parentId); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }