Esempio n. 1
0
        public void TestOneToMany()
        {
            PhoneEntity[] mPhones = new PhoneEntity[5];
            PhoneEntity[] tPhones = new PhoneEntity[5];
            for (int index = 0; index < 5; index++)
            {
                mPhones[index] = new PhoneEntity('M', "158-" + index);
                tPhones[index] = new PhoneEntity('T', "020-" + index);
            }
            PhoneDao phoneDao = new PhoneDao();

            phoneDao.save(mPhones);
            phoneDao.save(tPhones);

            CatEntity           cat    = new CatEntity("lisi", 'F', 100.0f);
            IList <PhoneEntity> phones = new List <PhoneEntity>();

            phones.Add(mPhones[0]);
            phones.Add(tPhones[0]);
            cat.Phones = phones;
            CatDao catDao = new CatDao();

            catDao.save(cat);

            CatEntity getCat = catDao.getByName("lisi");
        }
Esempio n. 2
0
    //Add
    internal string AddSql(CatEntity data)
    {
        string colNames = "";
        string colValue = "";

        colNames += " Id ";
        colValue += " " + this.GetNewId() + " ";

        colNames += ",Name_Ar";
        colValue += ",'" + data.Name_Ar + "'";

        colNames += ",Name_En";
        colValue += ",'" + data.Name_En + "'";

        colNames += ",DepartmentId";
        colValue += "," + data.DepartmentData.Id + "";

        colNames += ",RowId";
        colValue += ",'" + data.RowId + "'";

        colNames += ",DateMade";
        colValue += ",'" + this.dbHelper.GetServerDate().ToDateVal().FormatDate("MM/dd/yyyy HH:mm") + "'";

        colNames += ",MadeById";
        colValue += "," + data.MadeById + "";

        //-------------------------------
        string sql = " INSERT INTO Cat ( " + colNames + " ) VALUES ( " + colValue + " ) ";

        return(sql);
    }
Esempio n. 3
0
    public int Add(CatEntity data)
    {
        string sql = this.AddSql(data);
        int    x   = this.dbHelper.whriteData(sql);

        return(x);
    }
Esempio n. 4
0
    public List <CatEntity> GetList(int departId)
    {
        List <CatEntity> lst = null;

        DataTable table;
        string    sql = this.GetSql();

        sql += " WHERE  DepartmentId = " + departId + "";

        table = this.dbHelper.retriveData(sql);

        if (table != null && table.Rows.Count > 0)
        {
            lst = new List <CatEntity>();

            foreach (DataRow row in table.Rows)
            {
                CatEntity data = new CatEntity();
                this.SetData(row, data);

                lst.Add(data);
            }
        }
        return(lst);
    }
Esempio n. 5
0
        protected void buttonAddCat_Click(object sender, EventArgs e)
        {
            CatDao    dao = new CatDao();
            CatEntity cat = new CatEntity("cat1", 'F', 10.0f);

            dao.save(cat);
        }
Esempio n. 6
0
        public string save(CatEntity cat)
        {
            ITransaction tx         = session.BeginTransaction();
            String       generateId = session.Save(cat) as string;

            tx.Commit();
            return(generateId);
        }
Esempio n. 7
0
    public int Update(int id, CatEntity data)
    {
        string sql = this.UpdateSql(id, data);

        int x = this.dbHelper.whriteData(sql);

        return(x);
    }
Esempio n. 8
0
 private CatEntity[] createCatsWithoutDepartment()
 {
     CatEntity[] cats = new CatEntity[5];
     for (int index = 0; index < cats.Length; index++)
     {
         cats[index] = new CatEntity("cat_index" + index, 'F', 8.0f);
     }
     return(cats);
 }
        public UpdateOneCatParameters(CatEntity cat)
        {
            StoredProcedure = StoredProceduresEnum.UpdateOneCat;

            Id     = cat.Id;
            Views  = cat.ViewsNumber;
            Weight = cat.ProbabilityWeight;
            Rating = cat.Rating;
            Wins   = cat.Wins;
        }
Esempio n. 10
0
    private void SetData(DataRow Row, CatEntity data)
    {
        data.Id                = Row["Id"].ToString().ToIntVal();
        data.Name_Ar           = Row["Name_Ar"].ToString();
        data.Name_En           = Row["Name_En"].ToString();
        data.DepartmentData.Id = Row["DepartmentId"].ToString().ToIntVal();
        data.RowId             = Row["RowId"].ToString();
        data.DateMade          = Row["DateMade"].ToString().ToDateVal();

        data.MadeById = Row["MadeById"].ToString().ToIntVal();
    }
Esempio n. 11
0
        //--
        //-- Applicative logic : should be factorized in Applicatio Layer (CatMash.Core.Application)
        //--
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public async Task <CatEntity> PatchLoserCat(CatEntity winner)
        {
            var parameters = new CountViewsParameters();
            int totalViews = await repository.GetOneAsync <int, CountViewsParameters>(parameters);

            winner.ApplyLoose(totalViews);

            var updateParameter = new UpdateOneCatParameters(winner);

            winner = await repository.GetCatAsync <UpdateOneCatParameters>(updateParameter);

            return(winner);
        }
Esempio n. 12
0
    //Update
    public string UpdateSql(int id, CatEntity data)
    {
        string sql = "UPDATE Cat SET   ";

        sql += " Name_Ar = '" + data.Name_Ar + "' ";
        sql += ",Name_En = '" + data.Name_En + "' ";
        sql += ",DepartmentId = " + data.DepartmentData.Id + " ";
        //---------------
        sql += ",DateMade = '" + this.dbHelper.GetServerDate().ToDateVal().FormatDate("MM/dd/yyyy HH:mm") + "'";

        sql += ",MadeById = " + data.MadeById + "";

        sql += " WHERE Id = " + id + " ";

        return(sql);
    }
Esempio n. 13
0
    public bool GetData()
    {
        bool      x    = false;
        CatEntity data = delGetData(this.Id);

        if (!data.IsNull_Ex())
        {
            x             = true;
            this.Id       = data.Id;
            this.DateMade = data.DateMade;

            this.MadeById          = data.MadeById;
            this.Name_Ar           = data.Name_Ar;
            this.Name_En           = data.Name_En;
            this.DepartmentData.Id = data.DepartmentData.Id;
            this.RowId             = data.RowId;
        }
        return(x);
    }
Esempio n. 14
0
    public CatEntity GetData(string rowId)
    {
        CatEntity data = null;

        DataTable table;
        string    sql = this.GetSql();

        sql += " WHERE RowId = '" + rowId + "' ";

        table = this.dbHelper.retriveData(sql);


        if (table != null && table.Rows.Count > 0)
        {
            DataRow row = table.Rows[0];

            data = new CatEntity();
            this.SetData(row, data);
        }

        return(data);
    }