public ResponseModel GetStoreNotifications() { ResponseModel objResponseModel = new ResponseModel(); ListStoreNotificationModels objresponseModel = new ListStoreNotificationModels(); int statusCode = 0; string statusMessage = ""; try { //Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromToken(radisCacheServerAddress, SecurityService.DecryptStringAES(token)); StoreNotificationCaller storeNotificationCaller = new StoreNotificationCaller(); objresponseModel = storeNotificationCaller.GetNotification(new StoreNotificationService(connectioSting), authenticate.TenantId, authenticate.UserMasterID); statusCode = objresponseModel == null ? (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = objresponseModel; } catch (Exception) { throw; } return(objResponseModel); }
public ListStoreNotificationModels GetNotification(int tenantID, int userID) { List <StoreNotificationModel> ListstoreNotificationModel = new List <StoreNotificationModel>(); ListStoreNotificationModels storeNotificationModels = new ListStoreNotificationModels(); DataSet ds = new DataSet(); MySqlCommand cmd = new MySqlCommand(); try { conn.Open(); cmd.Connection = conn; MySqlCommand cmd1 = new MySqlCommand("SP_GetStoreNotifications", conn); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@Tenant_ID", tenantID); cmd1.Parameters.AddWithValue("@User_ID", userID); MySqlDataAdapter da = new MySqlDataAdapter(); da.SelectCommand = cmd1; da.Fill(ds); if (ds != null && ds.Tables[0] != null) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { StoreNotificationModel storeNotificationModel = new StoreNotificationModel(); storeNotificationModel.NotificationCount = ds.Tables[0].Rows[i]["NotificationCount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["NotificationCount"]); storeNotificationModel.AlertID = ds.Tables[0].Rows[i]["AlertID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["AlertID"]); storeNotificationModel.NotificationName = ds.Tables[0].Rows[i]["NotificationName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["NotificationName"]); int alertID = Convert.ToInt32(ds.Tables[0].Rows[i]["AlertID"]); storeNotificationModel.CustomTaskNotificationModels = ds.Tables[1].AsEnumerable().Where(x => Convert.ToInt32(x.Field <int>("AlertID")). Equals(alertID)).Select(x => new CustomTaskNotificationModel() { NotificationID = Convert.ToInt32(x.Field <int>("NotificationID")), AlertID = Convert.ToInt32(x.Field <int>("AlertID")), NotificatonTypeID = Convert.ToInt32(x.Field <int>("NotificatonTypeID")), NotificatonType = Convert.ToInt32(x.Field <int>("NotificatonType")), NotificatonTypeName = x.Field <object>("NotificatonTypeName") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("NotificatonTypeName")) }).ToList(); ListstoreNotificationModel.Add(storeNotificationModel); if (ListstoreNotificationModel.Count > 0) { storeNotificationModels.StoreNotificationModel = ListstoreNotificationModel; storeNotificationModels.NotiCount = ListstoreNotificationModel.Select(x => x.NotificationCount).Sum(); } } } } catch (Exception) { throw; } finally { if (ds != null) { ds.Dispose(); } conn.Close(); } return(storeNotificationModels); }