Esempio n. 1
0
        public static List<ExpertDataModel> Filter(ExpertDataModel model)
        {
            List<ExpertDataModel> items = new List<ExpertDataModel>();

            MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[Plenum.Data.Constants.AppSetting]);
            string FilterSelect = "" +
                " SELECT  ID,  Name,  LastName,  Mobile,  Bio  " +
                " FROM expert " +
                " WHERE Mobile LIKE '%" + model.Mobile.Replace("'","").Replace("-","") + "%'";

            MySqlDataAdapter adapter = new MySqlDataAdapter(FilterSelect, connection);
            adapter.SelectCommand.CommandType = CommandType.Text;

            DataTable results = new DataTable();

            adapter.Fill(results);

            foreach (DataRow row in results.Rows)
            {
                ExpertDataModel item = MapItem(row);
                items.Add(item);
            }

            return items;
        }
Esempio n. 2
0
        public static int Create(ExpertDataModel item)
        {
            MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[Plenum.Data.Constants.AppSetting]);
            MySqlDataAdapter adapter = new MySqlDataAdapter("Core_CreateExpert", connection);
            adapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                        MySqlParameter paramID = new MySqlParameter("pID", item.ID);
            paramID.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramID);
                    MySqlParameter paramName = new MySqlParameter("pName", item.Name);
            paramName.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramName);
                    MySqlParameter paramLastName = new MySqlParameter("pLastName", item.LastName);
            paramLastName.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramLastName);
                    MySqlParameter paramMobile = new MySqlParameter("pMobile", item.Mobile);
            paramMobile.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramMobile);
                    MySqlParameter paramBio = new MySqlParameter("pBio", item.Bio);
            paramBio.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramBio);

            DataTable results = new DataTable();
            adapter.Fill(results);

            if(results.Rows.Count > 0)
            {
                return Convert.ToInt32(results.Rows[0]["ID"]);
            }else{
                throw new Exception("Error creating Expert");
            }
        }
Esempio n. 3
0
        public virtual int CreateOrUpdate(ExpertDataModel item)
        {
            if (item.ID > 0)
            {
                ExpertDAL.Update(item);
            }
            else
            {
                item.ID = ExpertDAL.Create(item);
            }

            return Convert.ToInt32(item.ID);
        }
Esempio n. 4
0
        public ActionResult Edit(ExpertDataModel item)
        {
            ExpertBO.GetInstance().CreateOrUpdate(item);

            if (Session["ExpertParentID"] != null)
            {
                return RedirectToAction("Index", new { id = Convert.ToInt32(Session["ExpertParentID"]) });
            }
            else
            {
                return RedirectToAction("Index");
            }
        }
Esempio n. 5
0
        public override int CreateOrUpdate(ExpertDataModel item)
        {
            item.ID = base.CreateOrUpdate(item);

            //Skills sent?
            if(item.Skills != null && item.Skills.Count > 0){

                //Delete Previous Skills
                ExpertDAL.DeleteExpertAllSkills(Convert.ToInt32(item.ID));

                foreach (var skillItem in item.Skills)
                {
                    AddSkill(Convert.ToInt32(skillItem.ID), Convert.ToInt32(item.ID), Convert.ToInt32(item.ID));
                }
            }

            return Convert.ToInt32(item.ID);
        }
Esempio n. 6
0
        //
        // GET: /ManageRole/
        public ActionResult Index(ExpertDataModel model)
        {
            List<ExpertDataModel> list;
            if (model != null && !String.IsNullOrEmpty(model.Mobile))
            {
                list = ExpertBO.GetInstance().Filter(model);
            }
            else
            {
                if (model.ID != null && model.ID > 0)
                {
                    list = ExpertBO.GetInstance().GetAll(Convert.ToInt32(model.ID));
                }
                else
                {
                    list = ExpertBO.GetInstance().GetAll();
                }
            }

            return View(list);
        }
Esempio n. 7
0
 public JsonResult GetByMobile(ExpertDataModel expert, int fromExpertID)
 {
     return Json(ExpertBO.GetInstance().GetByMobile(expert, fromExpertID, true), JsonRequestBehavior.AllowGet);
 }
Esempio n. 8
0
        public JsonResult Update(ExpertDataModel expert)
        {
            ExpertBO.GetInstance().CreateOrUpdate(expert);

            return Json(new { success = true }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 9
0
        public void SetExpertContacts(ExpertDataModel expert, List<ExpertDataModel> contacts)
        {
            ExpertDAL.DeleteContacts(Convert.ToInt32(expert.ID));
            foreach (var item in contacts)
            {
                try
                {
                    //Remove + and " " chars
                    item.Mobile = FormatMobileNumber(item.Mobile);

                    //Create if it does not exist
                    ExpertDataModel model = ExpertDAL.GetByMobile(item.Mobile);
                    if (model == null)
                    {
                        model = item;
                        model.ID = CreateOrUpdate(item);
                    }
                    ExpertDAL.AddContact(Convert.ToInt32(expert.ID), Convert.ToInt32(model.ID));
                }
                catch (Exception ex)
                {
                    System.IO.File.AppendAllText(@"C:\Plenum\Laboru\WebServices\Logs\Errors.txt", "\r\n" + DateTime.Now.ToString() + item.Name + " " +
                        item.Mobile + " " + ex.Message);
                }
            }
        }
Esempio n. 10
0
        public ExpertDataModel Register(ExpertDataModel item)
        {
            //Remove + and " " chars
            item.Mobile = FormatMobileNumber(item.Mobile);

            ExpertDataModel model = ExpertDAL.GetByMobile(item.Mobile);
            if (model != null)
            {
                //Set ID so info is updated (Name)
                item.ID = model.ID;
                item.DateCreated = DateTime.Now;
            }

            item.ID = CreateOrUpdate(item);

            return  item;
        }
Esempio n. 11
0
        public ExpertDataModel GetByMobile(ExpertDataModel item,int fromExpertID, bool useCache = false)
        {
            item.Mobile = FormatMobileNumber(item.Mobile);
            //Create if it does not exist
            ExpertDataModel model = ExpertDAL.GetByMobile(item.Mobile);
            if (model == null)
            {
                model = item;
                model.ID = CreateOrUpdate(item);
                ExpertDAL.AddContact(fromExpertID, Convert.ToInt32(model.ID));
            }
            else
            {
                //Add Contact as Friend if not done yet
                IList<ExpertSearchResultDataModel> contact = ExpertDAL.GetExpertContact(Convert.ToInt32(model.ID), fromExpertID);
                if (contact == null || contact.Count == 0)
                {
                    ExpertDAL.AddContact(fromExpertID, Convert.ToInt32(model.ID));
                }
            }
            model.Skills = ExpertDAL.GetSkills(Convert.ToInt32(model.ID), fromExpertID);

            return model;
        }
Esempio n. 12
0
 public virtual List<ExpertDataModel> Filter(ExpertDataModel model)
 {
     return ExpertDAL.Filter(model);
 }
Esempio n. 13
0
        public static void Update(ExpertDataModel item)
        {
            MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[Plenum.Data.Constants.AppSetting]);
            MySqlDataAdapter adapter = new MySqlDataAdapter("Core_UpdateExpert", connection);
            adapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                        MySqlParameter paramID = new MySqlParameter("pID", item.ID);
            paramID.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramID);
                    MySqlParameter paramName = new MySqlParameter("pName", item.Name);
            paramName.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramName);
                    MySqlParameter paramLastName = new MySqlParameter("pLastName", item.LastName);
            paramLastName.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramLastName);
                    MySqlParameter paramMobile = new MySqlParameter("pMobile", item.Mobile);
            paramMobile.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramMobile);
                    MySqlParameter paramBio = new MySqlParameter("pBio", item.Bio);
            paramBio.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramBio);

            DataTable results = new DataTable();
            adapter.Fill(results);
        }
Esempio n. 14
0
        public static ExpertDataModel MapItem(DataRow row)
        {
            ExpertDataModel item = null;
            item = new ExpertDataModel();

            if (row["ID"].GetType() != typeof(DBNull))
            {
                item.ID = Convert.ToInt32(row["ID"]);
            }
            if (row["Name"].GetType() != typeof(DBNull))
            {
                item.Name = Convert.ToString(row["Name"]);
            }
            if (row["LastName"].GetType() != typeof(DBNull))
            {
                item.LastName = Convert.ToString(row["LastName"]);
            }
            if (row["Mobile"].GetType() != typeof(DBNull))
            {
                item.Mobile = Convert.ToString(row["Mobile"]);
            }
            if (row["Bio"].GetType() != typeof(DBNull))
            {
                item.Bio = Convert.ToString(row["Bio"]);
            }
            if (row.Table.Columns.Contains("DateCreated") && row["DateCreated"].GetType() != typeof(DBNull))
            {
                item.DateCreated = Convert.ToDateTime(row["DateCreated"]);
            }

            return item;
        }