Exemplo n.º 1
0
        public ActionResult <string> CreateCandidate([FromBody] CandidateCVInfo value, [FromQuery] string apikey, [FromQuery] string userkey, [FromQuery] string consumerkey, [FromQuery] string token, [FromQuery] int userid)
        {
            string jsonResult = "";

            if (AuthenticateUser() == false)
            {
                return(Unauthorized());
            }

            /* if (apikey != "123")
             * {
             *   return Unauthorized();
             * }*/

            string conStr = configuration.GetSection("Data").GetSection("ConntectionString").Value;

            RTS.JobStation.Controller.Candidate CandidateController = new RTS.JobStation.Controller.Candidate();

            MySql.Data.MySqlClient.MySqlConnection  con    = null;
            MySql.Data.MySqlClient.MySqlTransaction MyTran = null;


            try
            {
                con    = RTS.JobStation.DatabaseCommands.OpenConnection();
                MyTran = RTS.JobStation.DatabaseCommands.OpenTransaction(ref con);

                //Get Candidate Basic Info  GetCandidateBasicInfo
                RTS.JobStation.Models.Candidate candidate = new RTS.JobStation.Models.Candidate();
                candidate.cvTitle              = value.cvTitle;
                candidate.Objective            = value.Objective;
                candidate.RefNo                = value.RefNo;
                candidate.ExternalRefNo        = value.ExternalRefNo;
                candidate.NameFirst            = value.NameFirst;
                candidate.NameMiddle           = value.NameMiddle;
                candidate.NameLast             = value.NameLast;
                candidate.cvFIle               = value.cvFIle;
                candidate.cvMimeType           = value.cvFIle.Substring(value.cvFIle.IndexOf(".") + 1, 3);
                candidate.DateOfBirth          = value.DateOfBirth;
                candidate.Gender               = value.Gender;
                candidate.ReligionID           = value.ReligionID;
                candidate.CasteID              = value.CasteID;
                candidate.MaritialStatus       = value.MaritialStatus;
                candidate.NoOfDependant        = value.NoOfDependant;
                candidate.Nationality          = value.Nationality;
                candidate.CountryOfResidence   = value.CountryOfResidence;
                candidate.CityID               = value.CityID;
                candidate.VisaStatusID         = value.VisaStatusID;
                candidate.NoticePeriod         = value.NoticePeriod;
                candidate.Email                = value.Email;
                candidate.uPassword            = value.uPassword;
                candidate.MobileCountryCode    = value.MobileCountryCode;
                candidate.MobileNo             = value.MobileNo;
                candidate.Address              = value.Address;
                candidate.PoBox                = value.PoBox;
                candidate.FaxCountryCode       = value.PoBox;
                candidate.FaxNo                = value.FaxNo;
                candidate.isRelativeAtCompany  = value.isRelativeAtCompany;
                candidate.RelativeDetails      = value.RelativeDetails;
                candidate.WhyShurooq           = value.WhyShurooq;
                candidate.WorkExperienceTotal  = value.WorkExperienceTotal;
                candidate.WorkExperienceUAE    = value.WorkExperienceUAE;
                candidate.WorkExperienceNonUAE = value.WorkExperienceNonUAE;
                candidate.RelevantExperience   = value.RelevantExperience;
                candidate.UpdatedBy            = Request.Headers["userid"];
                candidate.UpdatedOn            = DateTime.Now;

                string result = CandidateController.Insert(candidate, ref con, ref MyTran);
                if (result == "300")
                {
                    return(StatusCode(501, "A candidate with " + value.Email + " already exist"));
                }

                int CandidateID = Int32.Parse(JobStation.DatabaseCommands.GetLastInsertedID(ref con, ref MyTran).ToString());
                if (CandidateID == 0)
                {
                    return(StatusCode(500, "Error. "));
                }

                jsonResult = CandidateID.ToString();
                CreateCandidateProfileAsync(value, CandidateID);
                return(Ok(jsonResult));
            }
            catch
            {
                return(StatusCode(500));
            }

            finally
            {
                RTS.JobStation.DatabaseCommands.CloseTransaction(ref MyTran);
                RTS.JobStation.DatabaseCommands.CloseConnection(ref con);
            }
        }
Exemplo n.º 2
0
        //  public ActionResult<IEnumerable<RTS.JobStation.Models.Religion>> Get()
        public ActionResult <string> Get()
        {
            if (AuthenticateUser() == false)
            {
                return(Unauthorized());
            }


            string conStr = configuration.GetSection("Data").GetSection("ConntectionString").Value;

            RTS.JobStation.Controller.Candidate candidate = new RTS.JobStation.Controller.Candidate();


            DataTable dt = new DataTable();
            List <RTS.JobStation.Models.Religion> ReligionList = new List <RTS.JobStation.Models.Religion>();

            MySql.Data.MySqlClient.MySqlConnection  con = RTS.JobStation.DatabaseCommands.OpenConnection();
            MySql.Data.MySqlClient.MySqlTransaction MyTran;
            MyTran = RTS.JobStation.DatabaseCommands.OpenTransaction(ref con);

            //Get All Relgion
            RTS.JobStation.Controller.Religion religion = new RTS.JobStation.Controller.Religion();
            dt = religion.GetAllReligion(ref con, ref MyTran).Tables[0];
            string json1 = JsonConvert.SerializeObject(dt);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                RTS.JobStation.Models.Religion religionM = new RTS.JobStation.Models.Religion();
                religionM.ReligionID = Convert.ToInt32(dt.Rows[i]["ReligionID"]);
                religionM.Religion   = dt.Rows[i]["Religion"].ToString();
                ReligionList.Add(religionM);
            }



            string json = JsonConvert.SerializeObject(ReligionList);
            //Deserialize the JSon value and assign it to datatable
            DataTable dtValue = (DataTable)JsonConvert.DeserializeObject(json, (typeof(DataTable)));



            DataSet ds = new DataSet("DataSet");
            // Table for parents
            DataTable parentTable = new DataTable("Parents");

            parentTable.Columns.Add("ParentId", typeof(int));
            parentTable.Columns.Add("ParentName", typeof(string));


            //Create some parents.


            parentTable.Rows.Add(new object[] { 1, "Parent # 1" });
            parentTable.Rows.Add(new object[] { 2, "Parent # 2" });
            parentTable.Rows.Add(new object[] { 3, "Parent # 3" });


            ds.Tables.Add(parentTable);

            // Table for childrend


            DataTable childTable = new DataTable("Childs");

            childTable.Columns.Add("ChildId", typeof(int));
            childTable.Columns.Add("ChildName", typeof(string));
            childTable.Columns.Add("ParentId", typeof(int));


            //Create some childs.


            childTable.Rows.Add(new object[] { 1, "Child # 1", 1 });
            childTable.Rows.Add(new object[] { 2, "Child # 2", 2 });
            childTable.Rows.Add(new object[] { 3, "Child # 3", 1 });
            childTable.Rows.Add(new object[] { 4, "Child # 4", 3 });
            childTable.Rows.Add(new object[] { 5, "Child # 5", 3 });
            ds.Tables.Add(childTable);


            // Create their relation.


            DataRelation parentChildRelation = new DataRelation("ParentChild", parentTable.Columns["ParentId"], childTable.Columns["ParentId"], true);

            parentChildRelation.Nested = true;
            ds.Relations.Add(parentChildRelation);
            ds.DataSetName = "Candidate";

            string xml = ds.GetXml();

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            //string json2 = JsonConvert.SerializeObject(doc.GetElementsByTagName("Parents"));

            string json2 = JsonConvert.SerializeObject(doc);



            //Deserialize
            string    jsonD     = @"{'Parents':[{'ParentId':'1','ParentName':'Parent # 1','Childs':[{'ChildId':'1','ChildName':'Child # 1','ParentId':'1'},{'ChildId':'3','ChildName':'Child # 3','ParentId':'1'}]},{'ParentId':'2','ParentName':'Parent # 2','Childs':{'ChildId':'2','ChildName':'Child # 2','ParentId':'2'}},{'ParentId':'3','ParentName':'Parent # 3','Childs':[{'ChildId':'4','ChildName':'Child # 4','ParentId':'3'},{'ChildId':'5','ChildName':'Child # 5','ParentId':'3'}]}]}";
            DataSet   dataSet   = JsonConvert.DeserializeObject <DataSet>(jsonD);
            DataTable dataTable = dataSet.Tables[0];



            //if (db.StringSet("shabeeraug2018", "testValue123"))
            // {
            //     var val = db.StringGet("testKey");

            //  Console.WriteLine(val);
            //   }

            //db.KeyDelete("shabeeraug2018");
            //db.StringSet("shabeeraug2018", "testValue123");
            //db.StringSet("shabeeraug2018", "testValue12345");

            return(json2);



            //return ReligionList;

            //return new string[] { "value1", "value2" };
        }
Exemplo n.º 3
0
        public ActionResult <string> Get(int id)
        {
            string jsonResult = "";

            if (AuthenticateUser() == false)
            {
                return(Unauthorized());
            }

            int    userID = Int32.Parse(Request.Headers["userid"]);
            string conStr = configuration.GetSection("Data").GetSection("ConntectionString").Value;

            RTS.JobStation.Controller.Candidate Candidate = new RTS.JobStation.Controller.Candidate();
            // DataSet ds = new DataSet("CandidateTimeline");
            DataSet ds = new DataSet();

            MySql.Data.MySqlClient.MySqlConnection  con    = null;
            MySql.Data.MySqlClient.MySqlTransaction MyTran = null;
            try
            {
                con    = RTS.JobStation.DatabaseCommands.OpenConnection();
                MyTran = RTS.JobStation.DatabaseCommands.OpenTransaction(ref con);
                ds     = Candidate.GetCandidateDetails(ref con, ref MyTran, id, userID);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        string xml = ds.GetXml();



                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(xml);

                        var xTag = doc.GetElementsByTagName("EmploymentProfile");

                        if (xTag.Count == 1)
                        {
                            var attribute = doc.CreateAttribute("json", "Array", "http://james.newtonking.com/projects/json");
                            attribute.InnerText = "true";
                            attribute.Value     = "true";

                            var node = xTag.Item(0) as XmlElement;
                            node.Attributes.Append(attribute);
                        }

                        xTag = doc.GetElementsByTagName("AcademicProfile");
                        if (xTag.Count == 1)
                        {
                            var attribute = doc.CreateAttribute("json", "Array", "http://james.newtonking.com/projects/json");
                            attribute.InnerText = "true";
                            attribute.Value     = "true";

                            var node = xTag.Item(0) as XmlElement;
                            node.Attributes.Append(attribute);
                        }

                        xTag = doc.GetElementsByTagName("PastApplications");
                        if (xTag.Count == 1)
                        {
                            var attribute = doc.CreateAttribute("json", "Array", "http://james.newtonking.com/projects/json");
                            attribute.InnerText = "true";
                            attribute.Value     = "true";

                            var node = xTag.Item(0) as XmlElement;
                            node.Attributes.Append(attribute);
                        }

                        xTag = doc.GetElementsByTagName("ShortlistableJobs");
                        if (xTag.Count == 1)
                        {
                            var attribute = doc.CreateAttribute("json", "Array", "http://james.newtonking.com/projects/json");
                            attribute.InnerText = "true";
                            attribute.Value     = "true";

                            var node = xTag.Item(0) as XmlElement;
                            node.Attributes.Append(attribute);
                        }

                        //string json2 = JsonConvert.SerializeObject(doc.GetElementsByTagName("Parents"));
                        jsonResult = JsonConvert.SerializeObject(doc);
                    }
                    else
                    {
                        return(NoContent());
                    }
                }
                else
                {
                    return(NoContent());
                }


                // jsonResult = JsonConvert.SerializeObject(ds);
            }
            catch (System.IO.IOException e)
            {
                return(StatusCode(501, "Error" + e.Message.ToString()));
            }

            finally
            {
                RTS.JobStation.DatabaseCommands.CloseTransaction(ref MyTran);
                RTS.JobStation.DatabaseCommands.CloseConnection(ref con);
            }


            return(Ok(jsonResult));
        }