public response Update(int id, string fieldValueCollection)
        {
            //UtilizatorSetare item = JsonConvert.DeserializeObject<UtilizatorSetare>(Find(id).Message);
            UtilizatorSetare item = (UtilizatorSetare)(Find(id).Result);

            return(item.Update(fieldValueCollection));
        }
        public response Update(string fieldValueCollection)
        {
            UtilizatorSetare tmpItem = JsonConvert.DeserializeObject <UtilizatorSetare>(fieldValueCollection); // sa vedem daca merge asa sau trebuie cu JObject

            //return JsonConvert.DeserializeObject<UtilizatorSetare>(Find(Convert.ToInt32(tmpItem.ID)).Message).Update(fieldValueCollection);
            return(((UtilizatorSetare)(Find(Convert.ToInt32(tmpItem.ID)).Result)).Update(fieldValueCollection));
        }
 public response GetAll()
 {
     try
     {
         DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "UTILIZATORI_SETARIsp_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())
         {
             UtilizatorSetare a = new UtilizatorSetare(authenticatedUserId, connectionString, (IDataRecord)r);
             aList.Add(a);
         }
         r.Close(); r.Dispose();
         UtilizatorSetare[] toReturn = new UtilizatorSetare[aList.Count];
         for (int i = 0; i < aList.Count; i++)
         {
             toReturn[i] = (UtilizatorSetare)aList[i];
         }
         return(new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, 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)
         })); }
 }
 public response Find(int _id)
 {
     try
     {
         UtilizatorSetare item = new UtilizatorSetare(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)
         })); }
 }
        public response GetFiltered(string _sort, string _order, string _filter, string _limit)
        {
            try
            {
                try
                {
                    string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(UtilizatorSetare), _filter, authenticatedUserId, connectionString);
                    _filter = newFilter == null ? _filter : newFilter;
                }
                catch { }
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "UTILIZATORI_SETARIsp_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())
                 * {
                 *  UtilizatorSetare a = new UtilizatorSetare(authenticatedUserId, connectionString, (IDataRecord)r);
                 *  aList.Add(a);
                 * }
                 * r.Close(); r.Dispose(); da.CloseConnection();
                 * UtilizatorSetare[] toReturn = new UtilizatorSetare[aList.Count];
                 * for (int i = 0; i < aList.Count; i++)
                 *  toReturn[i] = (UtilizatorSetare)aList[i];
                 * return new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null);
                 */
                List <UtilizatorSetare> aList = new List <UtilizatorSetare>();
                MySqlDataReader         r     = da.ExecuteSelectQuery();
                while (r.Read())
                {
                    UtilizatorSetare a = new UtilizatorSetare(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)
                })); }
        }
Esempio n. 6
0
 /// <summary>
 /// Metoda pt. popularea relatiilor dintre utilizatori si setarile asignate utilizatorului curent
 /// </summary>
 /// <returns>vector de SOCISA.UtilizatoriSetariJson</returns>
 public response GetUtilizatoriSetari()
 {
     try
     {
         DataAccess      da    = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "UTILIZATORI_SETARIsp_GetByIdUtilizator", new object[] { new MySqlParameter("_ID_UTILIZATOR", this.ID) });
         MySqlDataReader r     = da.ExecuteSelectQuery();
         ArrayList       aList = new ArrayList();
         while (r.Read())
         {
             UtilizatorSetare a = new UtilizatorSetare(authenticatedUserId, connectionString, Convert.ToInt32(r["ID_SETARE"]));
             aList.Add(a);
         }
         UtilizatorSetare[] toReturn = new UtilizatorSetare[aList.Count];
         for (int i = 0; i < aList.Count; i++)
         {
             toReturn[i] = (UtilizatorSetare)aList[i];
         }
         return(new response(true, Newtonsoft.Json.JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null));
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>()
         {
             new Error(exp)
         })); }
 }
 public response GetChildren(UtilizatorSetare item, string tableName, int childrenId)
 {
     return(item.GetChildren(tableName, childrenId));
 }
 public response GetChildrens(UtilizatorSetare item, string tableName)
 {
     return(item.GetChildrens(tableName));
 }
 public response Delete(UtilizatorSetare item)
 {
     return(item.Delete());
 }
 public response Update(UtilizatorSetare item)
 {
     return(item.Update());
 }
 public response Insert(UtilizatorSetare item)
 {
     return(item.Insert());
 }
Esempio n. 12
0
        /// <summary>
        /// Metoda pentru stergerea utilizatorului curent
        /// </summary>
        /// <returns>SOCISA.response = new object(bool = status, string = error message, int = id-ul cheie returnat)</returns>
        public response Delete()
        {
            try
            {
                foreach (Action a in (Action[])this.GetActions().Result)
                {
                    UtilizatorAction ua = new UtilizatorAction(authenticatedUserId, connectionString);
                    ua.ID_UTILIZATOR = Convert.ToInt32(this.ID); ua.ID_ACTION = Convert.ToInt32(a.ID);
                    ua.Delete();
                }
            }
            catch (Exception exp) { LogWriter.Log(exp); }

            try
            {
                foreach (Drept d in (Drept[])this.GetDrepturi().Result)
                {
                    UtilizatorDrept ud = new UtilizatorDrept(authenticatedUserId, connectionString);
                    ud.ID_UTILIZATOR = Convert.ToInt32(this.ID); ud.ID_DREPT = Convert.ToInt32(d.ID);
                    ud.Delete();
                }
            }
            catch (Exception exp) { LogWriter.Log(exp); }

            try
            {
                foreach (Dosar d in (Dosar[])this.GetDosare().Result)
                {
                    UtilizatorDosar ud = new UtilizatorDosar(authenticatedUserId, connectionString);
                    ud.ID_UTILIZATOR = Convert.ToInt32(this.ID); ud.ID_DOSAR = Convert.ToInt32(d.ID);
                    ud.Delete();
                }
            }
            catch (Exception exp) { LogWriter.Log(exp); }

            try
            {
                foreach (SocietateAsigurare sa in (SocietateAsigurare[])this.GetSocietatiAdministrate().Result)
                {
                    UtilizatorSocietateAdministrata usa = new UtilizatorSocietateAdministrata(authenticatedUserId, connectionString);
                    usa.ID_UTILIZATOR = Convert.ToInt32(this.ID); usa.ID_SOCIETATE = Convert.ToInt32(sa.ID);
                    usa.Delete();
                }
            }
            catch (Exception exp) { LogWriter.Log(exp); }

            try
            {
                foreach (Setare s in (Setare[])this.GetSetari().Result)
                {
                    UtilizatorSetare us = new UtilizatorSetare(authenticatedUserId, connectionString);
                    us.ID_UTILIZATOR = Convert.ToInt32(this.ID); us.ID_SETARE = Convert.ToInt32(s.ID);
                    us.Delete();
                }
            }
            catch (Exception exp) { LogWriter.Log(exp); }

            response  toReturn    = new response(false, "", null, null, new List <Error>());;
            ArrayList _parameters = new ArrayList();

            _parameters.Add(new MySqlParameter("_ID", this.ID));
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "UTILIZATORIsp_soft_delete", _parameters.ToArray());

            toReturn = da.ExecuteDeleteQuery();
            return(toReturn);
        }