Ejemplo n.º 1
0
        public response Update(int id, string fieldValueCollection)
        {
            //UtilizatorAction item = JsonConvert.DeserializeObject<UtilizatorAction>(Find(id).Message);
            UtilizatorAction item = (UtilizatorAction)(Find(id).Result);

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

            //return JsonConvert.DeserializeObject<UtilizatorAction>(Find(Convert.ToInt32(tmpItem.ID)).Message).Update(fieldValueCollection);
            return(((UtilizatorAction)(Find(Convert.ToInt32(tmpItem.ID)).Result)).Update(fieldValueCollection));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Metoda pt. popularea relatiilor dintre utilizatori si actiunile asignate utilizatorului curent
 /// </summary>
 /// <returns>vector de SOCISA.UtilizatoriActionsJson</returns>
 public response GetUtilizatoriActions()
 {
     try
     {
         DataAccess      da    = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "UTILIZATORI_ACTIONSsp_GetByIdUtilizator", new object[] { new MySqlParameter("_ID_UTILIZATOR", this.ID) });
         MySqlDataReader r     = da.ExecuteSelectQuery();
         ArrayList       aList = new ArrayList();
         while (r.Read())
         {
             UtilizatorAction d = new UtilizatorAction(authenticatedUserId, connectionString, Convert.ToInt32(r["ID"]));
             aList.Add(d);
         }
         r.Close(); r.Dispose();
         UtilizatorAction[] toReturn = new UtilizatorAction[aList.Count];
         for (int i = 0; i < aList.Count; i++)
         {
             toReturn[i] = (UtilizatorAction)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)
         })); }
 }
Ejemplo n.º 4
0
 public response GetAll()
 {
     try
     {
         DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "UTILIZATORI_ACTIONSsp_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())
         {
             UtilizatorAction a = new UtilizatorAction(authenticatedUserId, connectionString, (IDataRecord)r);
             aList.Add(a);
         }
         r.Close(); r.Dispose();
         UtilizatorAction[] toReturn = new UtilizatorAction[aList.Count];
         for (int i = 0; i < aList.Count; i++)
         {
             toReturn[i] = (UtilizatorAction)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)
         })); }
 }
Ejemplo n.º 5
0
 public response Find(int _id)
 {
     try
     {
         UtilizatorAction item = new UtilizatorAction(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)
         })); }
 }
Ejemplo n.º 6
0
        public response GetFiltered(string _sort, string _order, string _filter, string _limit)
        {
            try
            {
                try
                {
                    string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(UtilizatorAction), _filter, authenticatedUserId, connectionString);
                    _filter = newFilter == null ? _filter : newFilter;
                }
                catch { }
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "UTILIZATORI_ACTIONSsp_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())
                 * {
                 *  UtilizatorAction a = new UtilizatorAction(authenticatedUserId, connectionString, (IDataRecord)r);
                 *  aList.Add(a);
                 * }
                 * r.Close(); r.Dispose(); da.CloseConnection();
                 * UtilizatorAction[] toReturn = new UtilizatorAction[aList.Count];
                 * for (int i = 0; i < aList.Count; i++)
                 *  toReturn[i] = (UtilizatorAction)aList[i];
                 * return new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null);
                 */
                List <UtilizatorAction> aList = new List <UtilizatorAction>();
                MySqlDataReader         r     = da.ExecuteSelectQuery();
                while (r.Read())
                {
                    UtilizatorAction a = new UtilizatorAction(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)
                })); }
        }
Ejemplo n.º 7
0
 public response GetChildren(UtilizatorAction item, string tableName, int childrenId)
 {
     return(item.GetChildren(tableName, childrenId));
 }
Ejemplo n.º 8
0
 public response GetChildrens(UtilizatorAction item, string tableName)
 {
     return(item.GetChildrens(tableName));
 }
Ejemplo n.º 9
0
 public response Delete(UtilizatorAction item)
 {
     return(item.Delete());
 }
Ejemplo n.º 10
0
 public response Update(UtilizatorAction item)
 {
     return(item.Update());
 }
Ejemplo n.º 11
0
 public response Insert(UtilizatorAction item)
 {
     return(item.Insert());
 }
Ejemplo 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);
        }