public static int FeatureInsert(Features feature, out string errorMessage, bool isUnitTest = false) { int id = -1; try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); IEmailTools emailTools = AppTools.InitEmailTools(isUnitTest); errorMessage = ValidateFeature(feature); if (string.IsNullOrEmpty(errorMessage)) { id = sprocCalls.FeaturesInsert(feature); if (id <= 0) { errorMessage = "Error inserting new feature " + feature.FeatureName + "."; } //else // emailTools.SendToAll("New Feature created : " + feature.FeatureName + "<br />Description : " + feature.FeatureDescription); } } catch (Exception ex) { errorMessage = ex.Message; DBCommands.RecordError(ex); } return(id); }
public static List <FeatureRequested> RequestedFeaturesByBusiness(int businessID, bool isUnitTest = false) { List <FeatureRequested> features = new List <FeatureRequested>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); DataTable featureTable = sprocCalls.BusinessRequestedFeature(businessID); FeatureRequested requestFeature; foreach (DataRow row in featureTable.Rows) { requestFeature = new FeatureRequested(); requestFeature.Active = Convert.ToBoolean(row["Active"]); requestFeature.AppRequestID = Convert.ToInt32(row["AppRequestID"]); requestFeature.AssignedTo = (row["AssignedTo"] != DBNull.Value) ? UserManager.GetUserByName(row["AssignedTo"].ToString()) : null; requestFeature.DateRequested = (row["DateRequested"] != DBNull.Value) ? Convert.ToDateTime(row["DateRequested"]) : (DateTime?)null; requestFeature.DevStatus = (row["DevStatus"] != DBNull.Value) ? row["DevStatus"].ToString() : ""; requestFeature.FeatureRequestedID = Convert.ToInt32(row["FeatureRequestedID"]); requestFeature.RequestedFeature = FeatureGetByID(Convert.ToInt32(row["FeatureID"])); features.Add(requestFeature); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(features); }
public static void UpdateUser(UserInfo user, out string errorMessage, bool isTest = false) { try { errorMessage = ValidateUser(user); if (string.IsNullOrEmpty(errorMessage)) { IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest); ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); if (membershipTools.UpdateUserEmail(user.UserName, user.Email) == false) { errorMessage = "Error updating email."; } if (sprocCalls.UserInfoUpdate(user) == false) { errorMessage = "Error saving user information"; } } } catch (Exception ex) { DBCommands.RecordError(ex); errorMessage = ex.Message; } }
public static List <Features> GetAllFeatures(bool allActive, bool isUnitTest = false) { List <Features> allFeatures = new List <Features>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); DataTable featureTable = sprocCalls.FeaturesGetAll(); foreach (DataRow row in featureTable.Rows) { Features feature = new Features(); feature.Active = allActive; feature.FeatureDescription = (row["FeatureDescription"] != DBNull.Value) ? row["FeatureDescription"].ToString() : ""; feature.FeatureID = Convert.ToInt32(row["FeatureID"]); feature.FeatureName = row["FeatureName"].ToString(); feature.MainFeature = Convert.ToBoolean(row["MainFeature"]); allFeatures.Add(feature); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(allFeatures); }
public static List <UserGroups> GroupsGetAll(bool isTest = false) { List <UserGroups> groupList = new List <UserGroups>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); DataTable groupTable = sprocCalls.UserGroupsGetActive(); UserGroups group; foreach (DataRow row in groupTable.Rows) { group = new UserGroups(); group.Active = false; group.GroupLevel = Convert.ToInt32(row["GroupLevel"]); group.GroupName = row["GroupName"].ToString(); group.UserGroupID = Convert.ToInt32(row["UserGroupID"]); groupList.Add(group); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(groupList); }
public static List <UserInfo> GetAllUsers(bool isTest = false) { List <UserInfo> allUsers = new List <UserInfo>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); DataTable userTable = sprocCalls.UserInfoGetAll(); UserInfo user; foreach (DataRow row in userTable.Rows) { user = new UserInfo(); user.UserInfoID = Convert.ToInt32(row["UserInfoID"]); user.UserName = row["UserName"].ToString(); user.Email = row["Email"].ToString(); user.ProfileImage = row["ProfileImage"].ToString(); user.GroupUsers = GetGroupsByUserName(user.UserName, sprocCalls); allUsers.Add(user); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(allUsers); }
public static List <AppRequest> AppRequestsGetAll(bool isUnitTest = false) { List <AppRequest> appRequests = new List <AppRequest>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); DataTable requestTable = sprocCalls.AppRequestsGetAll(); AppRequest request; foreach (DataRow row in requestTable.Rows) { request = new AppRequest(); request.Active = Convert.ToBoolean(row["Active"]); request.AppBusiness = sprocCalls.GetBusinessByID(Convert.ToInt32(row["BusinessID"])); request.AppRequestID = Convert.ToInt32(row["AppRequestID"]); request.DateRequested = Convert.ToDateTime(row["DateRequested"]); request.DevStatus = (row["DevStatus"] != DBNull.Value) ? row["DevStatus"].ToString() : ""; appRequests.Add(request); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(appRequests); }
public static UserInfo GetUserByName(string userName, bool isTest = false) { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); UserInfo user = sprocCalls.UserInfoGetByUser(userName); if (user != null) { user.GroupUsers = GetGroupsByUserName(userName, sprocCalls); } return(user); }
private static string InsertUser(UserInfo user, bool isTest) { string errorMessage = string.Empty; IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest); ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); if (membershipTools.CreateUser(user.UserName, user.Email, user.Password) == false || sprocCalls.UserInfoUpdate(user) == false) { errorMessage = "Error saving user information."; } return(errorMessage); }
public static Features FeatureGetByID(int featureID, bool IsUnitTest = false) { Features feature = null; try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(IsUnitTest); feature = sprocCalls.FeatureGetByID(featureID); } catch (Exception ex) { DBCommands.RecordError(ex); } return(feature); }
public static Business BusinessGetByUser(string userName, bool isTest = false) { Business business = new Business(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); business = sprocCalls.GetBusinessByUser(userName); business.user = UserManager.GetUserByName(userName); } catch (Exception ex) { DBCommands.RecordError(ex); } return(business); }
public static void FeatureDelete(int featureID, out string errorMessage, bool isUnitTest = false) { try { errorMessage = string.Empty; ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); if (sprocCalls.FeatureDelete(featureID) == false) { errorMessage = "Error deleting feature."; } } catch (Exception ex) { errorMessage = ex.Message; DBCommands.RecordError(ex); } }
private static List <UserGroups> GetGroupsByUserName(string userName, ISprocCalls sprocCalls) { List <UserGroups> groupList = new List <UserGroups>(); DataTable groupTable = sprocCalls.GroupUsersGetByUserName(userName); UserGroups group; foreach (DataRow row in groupTable.Rows) { group = new UserGroups(); group.UserGroupID = Convert.ToInt32(row["UserGroupID"]); group.GroupName = row["GroupName"].ToString(); group.GroupLevel = Convert.ToInt32(row["GroupLevel"]); group.Active = Convert.ToBoolean(row["Active"]); groupList.Add(group); } return(groupList); }
public static void FeatureUpdate(Features feature, out string errorMessage, bool isUnitTest = false) { try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); errorMessage = ValidateFeature(feature); if (string.IsNullOrEmpty(errorMessage)) { if (sprocCalls.FeaturesUpdate(feature) == false) { errorMessage = "Error updating feature " + feature.FeatureName + "."; } } } catch (Exception ex) { errorMessage = ex.Message; DBCommands.RecordError(ex); } }
public static void AppRequestUpdate(AppRequest request, out string errorMessage, bool isUnitTest = false) { try { errorMessage = ValidateRequest(request); if (string.IsNullOrEmpty(errorMessage)) { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); if (sprocCalls.AppRequestUpdate(request) == false) { errorMessage = "Error updating request."; } } } catch (Exception ex) { errorMessage = ex.Message; DBCommands.RecordError(ex); } }
public static void RequestFeatureUpdate(List <FeatureRequested> features, out string errorMessage, bool isUnitTest = false) { try { errorMessage = string.Empty; ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); foreach (FeatureRequested request in features) { if (sprocCalls.RequestedFeatureUpdate(request) == false) { errorMessage = "Error gathering all features"; } } } catch (Exception ex) { errorMessage = ex.Message; DBCommands.RecordError(ex); } }
public static void BusinessUpdate(Business business, out string errorMessage, bool isTest = false) { try { errorMessage = ValidateBusiness(business); if (string.IsNullOrEmpty(errorMessage)) { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); if (sprocCalls.BusinessUpdate(business) == false) { errorMessage = "Error updating business."; } } } catch (Exception ex) { errorMessage = ex.Message; DBCommands.RecordError(ex); } }
public static List <Business> BusinessGetAll(bool isTest = false) { List <Business> businesses = new List <Business>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); DataTable table = sprocCalls.BusinessGetAll(); Business business; foreach (DataRow row in table.Rows) { business = new Business(); business.AppLink = (row["AppLink"] != DBNull.Value) ? row["AppLink"].ToString() : ""; business.AppStatus = (row["AppStatus"] != DBNull.Value) ? row["AppStatus"].ToString() : ""; business.BusinessAddress = (row["BusinessAddress"] != DBNull.Value) ? row["BusinessAddress"].ToString() : ""; business.BusinessEmail = (row["BusinessEmail"] != DBNull.Value) ? row["BusinessEmail"].ToString() : ""; business.BusinessHoursEnd = (row["BusinessHoursEnd"] != DBNull.Value) ? row["BusinessHoursEnd"].ToString() : ""; business.BusinessHoursStart = (row["BusinessHoursStart"] != DBNull.Value) ? row["BusinessHoursStart"].ToString() : ""; business.BusinessID = Convert.ToInt32(row["BusinessID"]); business.BusinessName = (row["BusinessName"] != DBNull.Value) ? row["BusinessName"].ToString() : ""; business.BusinessPhone = (row["BusinessPhone"] != DBNull.Value) ? row["BusinessPhone"].ToString() : ""; business.FacebookUrl = (row["FacebookUrl"] != DBNull.Value) ? row["FacebokUrl"].ToString() : ""; business.ImageGalleryUrl = (row["ImageGalleryUrl"] != DBNull.Value) ? row["ImageGalleryUrl"].ToString() : ""; business.IsPublic = Convert.ToBoolean(row["IsPublic"] != DBNull.Value) ? Convert.ToBoolean(row["IsPublic"]) : false; business.Other = (row["Other"] != DBNull.Value) ? row["Other"].ToString() : ""; business.TypeOfBusiness = (row["TypeOfBusiness"] != DBNull.Value) ? row["TypeOfBusiness"].ToString() : ""; business.user = UserManager.GetUserByName(row["UserName"].ToString()); business.WebsiteUrl = (row["WebsiteUrl"] != DBNull.Value) ? row["WebsiteUrl"].ToString() : ""; businesses.Add(business); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(businesses); }
public static UserInfo GetUserByCode(CompleteRec model, string code, bool isTest = false) { UserInfo user = null; try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest); user = sprocCalls.UserInfoGetByCode(code); if (user.Email == model.Email) { if (membershipTools.UpdatePassword(model.UserName, model.Password)) { string errorMessage = string.Empty; user.GroupUsers = GetGroupsByUserName(user.UserName, sprocCalls); user.RecoverCode = null; UpdateUser(user, out errorMessage, isTest); if (string.IsNullOrEmpty(errorMessage) == false) { throw new Exception(errorMessage); } } } else { throw new Exception("User recovered email does not match."); } return(user); } catch (Exception ex) { DBCommands.RecordError(ex); } return(user); }
public static void RecoverPassword(RecoverModel model, string location, out string errorMessage, bool isTest = false) { try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); errorMessage = string.Empty; UserInfo user = sprocCalls.UserInfoGetByUser(model.UserName); if (model.Email == user.Email) { string code = RandomCode(7); while (sprocCalls.UserInfoGetByCode(code) != null) { code = RandomCode(7); } user.GroupUsers = GetGroupsByUserName(model.UserName, sprocCalls); user.RecoverCode = RandomCode(7); if (sprocCalls.UserInfoUpdate(user) == false) { errorMessage = "Error recovering password."; } else if (SendRecoverEmail(user, location, isTest) == false) { errorMessage = "Error sending email."; } } else { errorMessage = (user != null) ? "Email and username is not valid." : "Error loading user"; } } catch (Exception ex) { DBCommands.RecordError(ex); errorMessage = ex.Message; } }