Ejemplo n.º 1
0
    public bool merge(KeyWordDTO entity)
    {
        try
        {
            var addObj = (from p in ctx.KeyWords
                       where p.word == @entity.word && p.vacancyNumber == @entity.vacancyNumber
                       select p).Single();

            model.KeyWord obj = (KeyWord)addObj;

            /*Update*/
            obj.word = entity.word;
            obj.vacancyNumber = entity.vacancyNumber;

            ctx.SubmitChanges();
            return true;
        }
        catch (Exception e)
        {
            model.Log log = new Log();
            log.message = "KeyWord Merge: " + " [" + entity.word + " , " + entity.vacancyNumber + "] " + e.Message;

            ctx.Dispose();
            ctx = new ModelDataContext();
            ctx.SubmitChanges();

            return false;
        }
    }
Ejemplo n.º 2
0
    public KeyWordDTO find(string word, string vacancyNumber)
    {
        var obj = (from p in ctx.KeyWords
                   where p.word == @word && p.vacancyNumber == @vacancyNumber
                   select p).Single();

        KeyWordDTO add = new KeyWordDTO();
        add.vacancyNumber = obj.vacancyNumber;
        add.word = obj.word;

        return add;
    }
Ejemplo n.º 3
0
    public List<KeyWordDTO> findAll()
    {
        var objs = (from p in ctx.KeyWords
                    select p);
        KeyWordDTO add = null;
        List<KeyWordDTO> addList = new List<KeyWordDTO>();
        foreach (KeyWord obj in objs)
        {
            add = new KeyWordDTO();
            add.word = obj.word;
            add.vacancyNumber = obj.vacancyNumber;

            addList.Add(add);
        }
        return addList;
    }
Ejemplo n.º 4
0
    public KeyWordDTO find(string vacancyNumber, string keyWord)
    {
        KeyWordDTO info = new KeyWordDTO();
        SqlConnection oConn = new SqlConnection();
        SqlCommand sqlCmd = null;

        try
        {
            oConn.ConnectionString = ConfigurationManager.AppSettings["conn"];
            oConn.Open();

            sqlCmd = oConn.CreateCommand();
            sqlCmd.CommandType = CommandType.Text;
            sqlCmd.CommandText = "select * from KeyWord where vacancyNumber = '" + vacancyNumber + "' AND word = '" + keyWord + "'";

            SqlDataReader rdr = sqlCmd.ExecuteReader();

            if (rdr.HasRows)
            {
                while (rdr.Read())
                {
                    info.vacancyNumber = rdr["vacancyNumber"].ToString();
                    info.word = rdr["word"].ToString();
                }
            }

        }
        catch
        { }
        finally
        {
            if (sqlCmd != null)
            {
                sqlCmd = null;
            }
            if (oConn != null)
            {
                if (oConn.State.Equals(ConnectionState.Open))
                {
                    oConn.Close();
                }
                oConn = null;
            }
        }
        return info;
    }
Ejemplo n.º 5
0
        public void KeyWordDAO_Test()
        {
            /*Context*/
            KeyWordDAO key_context = new KeyWordDAO();
            VacancyDAO vac_context = new VacancyDAO();

            /*Insert*/
            VacancyDTO vac = new VacancyDTO();
            vac.department = "IS";
            vac.description = "Web services";
            vac.manager = "Tom";
            vac.recruiter = "Thumi";
            vac.site = "www.petrosa.co.za";
            vac.startDate = new DateTime(2012, 10, 10);
            vac.endDate = new DateTime(2012, 12, 1);
            vac.description = "desktop support";
            vac.title = "support technician";
            vac.vacancyNumber = "1";
            vac.viewCount = 10;
            vac.viewStatus = "published";
            vac.status = "active";

            vac_context.presist(vac);

            KeyWordDTO key = new KeyWordDTO();
            key.vacancyNumber = "1";
            key.word = "Fish";
            key_context.presist(key);
            bool expectedVac = true;
            bool actualVac;
            actualVac = key_context.isFound("Fish", "1");
            Assert.AreEqual(expectedVac, actualVac);

            /*Update*/
            //Not Applicable - Composite primary key can not be changed,except by removing the entity.

            /*Delete*/
            Assert.AreEqual(key_context.isFound("Fish", "1"), true);
            key_context.removeByUserId("Fish", "1");
            Assert.AreEqual(key_context.isFound("Fish", "1"), false);
            vac_context.removeByUserId("1");
        }
Ejemplo n.º 6
0
    public List<KeyWordDTO> findAll()
    {
        KeyWordDTO info = null;
        List<KeyWordDTO> infos = new List<KeyWordDTO>();
        SqlConnection oConn = new SqlConnection();
        SqlCommand sqlCmd = null;

        try
        {
            oConn.ConnectionString = ConfigurationManager.AppSettings["conn"];
            oConn.Open();

            sqlCmd = oConn.CreateCommand();
            sqlCmd.CommandType = CommandType.Text;
            sqlCmd.CommandText = "select * from KeyWord";

            SqlDataReader rdr = sqlCmd.ExecuteReader();

            if (rdr.HasRows)
            {
                while (rdr.Read())
                {
                    info = new KeyWordDTO();
                    info.vacancyNumber = rdr["vacancyNumber"].ToString();
                    info.word = rdr["word"].ToString();

                    infos.Add(info);
                }
            }

        }
        catch
        { }
        finally
        {
            if (sqlCmd != null)
            {
                sqlCmd = null;
            }
            if (oConn != null)
            {
                if (oConn.State.Equals(ConnectionState.Open))
                {
                    oConn.Close();
                }
                oConn = null;
            }
        }
        return infos;
    }
Ejemplo n.º 7
0
 public bool remove(KeyWordDTO entity)
 {
     return this.removeByUserId(entity.vacancyNumber, entity.word);
 }
Ejemplo n.º 8
0
    public bool presist(KeyWordDTO entity)
    {
        bool success = false;
        SqlConnection oConn = new SqlConnection();
        SqlCommand sqlCmd = null;

        try
        {
            oConn.ConnectionString = ConfigurationManager.AppSettings["conn"];
            oConn.Open();

            sqlCmd = oConn.CreateCommand();
            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.CommandText = "insertKeyWord";
            sqlCmd.Parameters.Add(new SqlParameter("vacancyNumber", entity.vacancyNumber));
            sqlCmd.Parameters.Add(new SqlParameter("word", entity.word));

            SqlDataReader rdr = sqlCmd.ExecuteReader();
            if (rdr.HasRows)
            {
                while (rdr.Read())
                { } //Read all
            }
            rdr.Close();

            if (rdr.RecordsAffected > 0)
                success = true;
        }
        catch { }
        finally
        {
            if (sqlCmd != null)
            {
                sqlCmd = null;
            }
            if (oConn != null)
            {
                if (oConn.State.Equals(ConnectionState.Open))
                {
                    oConn.Close();
                }
                oConn = null;
            }
        }
        return success;
    }
Ejemplo n.º 9
0
 public void ChangeKeyWord(KeyWordDTO keyWordDTO)
 {
     _personRepository.ChangeKeyWord(_mapper.Map <KeyWordDTO, KeyWord>(keyWordDTO));
 }
Ejemplo n.º 10
0
 public void AddKeyWord(KeyWordDTO keyWordDTO)
 {
     _personRepository.AddKeyWord(_mapper.Map <KeyWordDTO, KeyWord>(keyWordDTO));
 }
Ejemplo n.º 11
0
    public bool presist(KeyWordDTO entity)
    {
        try
        {
            model.KeyWord obj = new KeyWord();
            obj.word = entity.word;
            obj.vacancyNumber = entity.vacancyNumber;

            ctx.KeyWords.InsertOnSubmit(obj);
            ctx.SubmitChanges();
            return true;
        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
Ejemplo n.º 12
0
 public void setKeyWordDto(KeyWordDTO keyWordDto)
 {
     view.setKeyWord(keyWordDto.word);
 }
Ejemplo n.º 13
0
 public KeyWordDTO getKeyWordDto()
 {
     KeyWordDTO keyWordDto = new KeyWordDTO();
     keyWordDto.vacancyNumber = view.getVacancyNumber();
     keyWordDto.word = view.getKeyWord();
     return keyWordDto;
 }