Esempio n. 1
0
        private WorkerSkill ConvertToEntity(DataRow row)
        {
            try
            {
                WorkerSkill u = new WorkerSkill();
                u.UserId  = Int32.Parse(row["UserId"].ToString());
                u.SkillId = Int32.Parse(row["SkillId"].ToString());

                return(u);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 2
0
        public Result <WorkerSkill> Save(WorkerSkill WorkerSkill)
        {
            var result = new Result <WorkerSkill>();

            try
            {
                string query = "select * from WorkerSkill where UserId=" + WorkerSkill.UserId;
                var    dt    = DataAccess.GetDataTable(query);

                if (dt == null || dt.Rows.Count == 0)
                {
                    WorkerSkill.UserId = CurrentUser.User.UserId;
                    query = "insert into WorkerSkill values(" + WorkerSkill.UserId + "," + WorkerSkill.SkillId + ")";
                }
                else
                {
                    query = "update WorkerSkill set SkillId=" + WorkerSkill.SkillId + " where UserId=" + WorkerSkill.UserId;
                }

                result.HasError = DataAccess.ExecuteQuery(query) <= 0;

                if (result.HasError)
                {
                    result.Message = "Something Went Wrong";
                }
                else
                {
                    result.Data = WorkerSkill;
                }
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.Message  = ex.Message;
            }
            return(result);
        }
Esempio n. 3
0
        public List <WorkerSkill> GetAll()
        {
            var result = new List <WorkerSkill>();

            try
            {
                string query = "select * from WorkerSkill";
                var    dt    = DataAccess.GetDataTable(query);

                if (dt != null && dt.Rows.Count != 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        WorkerSkill u = ConvertToEntity(dt.Rows[i]);
                        result.Add(u);
                    }
                }
            }
            catch (Exception ex)
            {
                return(result);
            }
            return(result);
        }