Example #1
0
        public response Update(string fieldValueCollection)
        {
            EmailNotification tmpItem = JsonConvert.DeserializeObject <EmailNotification>(fieldValueCollection); // sa vedem daca merge asa sau trebuie cu JObject

            //return JsonConvert.DeserializeObject<EmailNotification>(Find(Convert.ToInt32(tmpItem.ID)).Message).Update(fieldValueCollection);
            return(((EmailNotification)(Find(Convert.ToInt32(tmpItem.ID)).Result)).Update(fieldValueCollection));
        }
Example #2
0
        public response Update(int id, string fieldValueCollection)
        {
            //EmailNotification item = JsonConvert.DeserializeObject<EmailNotification>(Find(id).Message);
            EmailNotification item = (EmailNotification)(Find(id).Result);

            return(item.Update(fieldValueCollection));
        }
Example #3
0
 public response Find(int _id)
 {
     try
     {
         EmailNotification item = new EmailNotification(authenticatedUserId, connectionString, _id);
         return(new response(true, JsonConvert.SerializeObject(item, CommonFunctions.JsonSerializerSettings), item, null, null));;
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
         {
             new Error(exp)
         })); }
 }
Example #4
0
        public response GetAll()
        {
            try
            {
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "EMAIL_NOTIFICATIONS_NEWsp_select", new object[] {
                    new MySqlParameter("_SORT", null),
                    new MySqlParameter("_ORDER", null),
                    new MySqlParameter("_FILTER", null),
                    new MySqlParameter("_LIMIT", null)
                });

                /*
                 * ArrayList aList = new ArrayList();
                 * MySqlDataReader r = da.ExecuteSelectQuery();
                 * while (r.Read())
                 * {
                 *  EmailNotification a = new EmailNotification(authenticatedUserId, connectionString, (IDataRecord)r);
                 *  aList.Add(a);
                 * }
                 * r.Close(); r.Dispose(); da.CloseConnection();
                 * EmailNotification[] toReturn = new EmailNotification[aList.Count];
                 * for (int i = 0; i < aList.Count; i++)
                 *  toReturn[i] = (EmailNotification)aList[i];
                 * return new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null);
                 */
                List <EmailNotification> aList = new List <EmailNotification>();
                MySqlDataReader          r     = da.ExecuteSelectQuery();
                while (r.Read())
                {
                    EmailNotification a = new EmailNotification(authenticatedUserId, connectionString, (IDataRecord)r);
                    aList.Add(a);
                }
                r.Close(); r.Dispose(); da.CloseConnection();
                return(new response(true, JsonConvert.SerializeObject(aList.ToArray(), CommonFunctions.JsonSerializerSettings), aList.ToArray(), null, null));
            }
            catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
                {
                    new Error(exp)
                })); }
        }
Example #5
0
 public response GetChildren(EmailNotification item, string tableName, int childrenId)
 {
     return(item.GetChildren(tableName, childrenId));
 }
Example #6
0
 public response GetChildrens(EmailNotification item, string tableName)
 {
     return(item.GetChildrens(tableName));
 }
Example #7
0
 public response Delete(EmailNotification item)
 {
     return(item.Delete());
 }
Example #8
0
 public response Update(EmailNotification item)
 {
     return(item.Update());
 }
Example #9
0
 public response Insert(EmailNotification item)
 {
     return(item.Insert());
 }
Example #10
0
        public response GetFiltered(string _sort, string _order, string _filter, string _limit)
        {
            try
            {
                #region -- initial --

                /*
                 * string newFilter = null;
                 * try
                 * {
                 *  try
                 *  {
                 *      EmailNotification x = Newtonsoft.Json.JsonConvert.DeserializeObject<EmailNotification>(_filter);
                 *      newFilter = x.GenerateFilterFromJsonObject();
                 *  }
                 *  catch
                 *  {
                 *      try
                 *      {
                 *          dynamic jObj = Newtonsoft.Json.JsonConvert.DeserializeObject(_filter);
                 *          EmailNotification x = new EmailNotification(authenticatedUserId, connectionString);
                 *          PropertyInfo[] pisX = x.GetType().GetProperties();
                 *          PropertyInfo[] pisJObj = jObj.GetType().GetProperties();
                 *          foreach (PropertyInfo piX in pisX)
                 *          {
                 *              foreach (PropertyInfo piJObj in pisJObj)
                 *              {
                 *                  if (piX.Name == piJObj.Name)
                 *                  {
                 *                      piX.SetValue(x, piJObj.GetValue(jObj));
                 *                      break;
                 *                  }
                 *              }
                 *          }
                 *          newFilter = x.GenerateFilterFromJsonObject();
                 *      }
                 *      catch { }
                 *  }
                 * }
                 * catch { }
                 * if (newFilter != null) _filter = newFilter;
                 */
                #endregion
                try
                {
                    string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(EmailNotification), _filter, authenticatedUserId, connectionString);
                    _filter = (newFilter == null || newFilter.Trim() == "") && !_filter.IsValidJson() ? _filter : String.IsNullOrWhiteSpace(newFilter) ? null : newFilter;
                }
                catch { }
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "EMAIL_NOTIFICATIONS_NEWsp_select", new object[] {
                    new MySqlParameter("_SORT", _sort),
                    new MySqlParameter("_ORDER", _order),
                    new MySqlParameter("_FILTER", _filter),
                    new MySqlParameter("_LIMIT", _limit)
                });

                /*
                 * ArrayList aList = new ArrayList();
                 * MySqlDataReader r = da.ExecuteSelectQuery();
                 * while (r.Read())
                 * {
                 *  EmailNotification a = new EmailNotification(authenticatedUserId, connectionString, (IDataRecord)r);
                 *  aList.Add(a);
                 * }
                 * r.Close(); r.Dispose(); da.CloseConnection();
                 * EmailNotification[] toReturn = new EmailNotification[aList.Count];
                 * for (int i = 0; i < aList.Count; i++)
                 *  toReturn[i] = (EmailNotification)aList[i];
                 * return new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null);
                 */
                List <EmailNotification> aList = new List <EmailNotification>();
                MySqlDataReader          r     = da.ExecuteSelectQuery();
                while (r.Read())
                {
                    EmailNotification a = new EmailNotification(authenticatedUserId, connectionString, (IDataRecord)r);
                    aList.Add(a);
                }
                r.Close(); r.Dispose(); da.CloseConnection();
                return(new response(true, JsonConvert.SerializeObject(aList.ToArray(), CommonFunctions.JsonSerializerSettings), aList.ToArray(), null, null));
            }
            catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
                {
                    new Error(exp)
                })); }
        }