public IHttpActionResult PuttrainInfoChange(tTraining data)
 {
     data.DateUpdated     = DateTime.Now;
     db.Entry(data).State = EntityState.Modified;
     db.SaveChanges();
     return(Json("success"));
 }
 public IHttpActionResult PutremoveTrnID(tTraining id)
 {
     id.DateUpdated     = DateTime.Now;
     id.Status          = 1;
     db.Entry(id).State = EntityState.Modified;
     db.SaveChanges();
     return(Json("success"));
 }
        public IHttpActionResult PostEdu(tTraining Trn)
        {
            Trn.DateCreated = DateTime.Now;
            Trn.Status      = 0;
            var aRole = db.tTrainings.Add(Trn);

            db.SaveChanges();
            return(Json(aRole));
        }
        public IHttpActionResult PostProfRequirements(ProfileReq data)
        {
            try
            {
                if (data.req.EduArr != null)
                {
                    var obj = new tEducationalBackground();
                    foreach (var a in data.req.EduArr)
                    {
                        obj.School      = a.School;
                        obj.Course      = a.Course;
                        obj.Address     = a.Address;
                        obj.DateStared  = a.DateStared;
                        obj.DateEnded   = a.DateEnded;
                        obj.DateCreated = DateTime.Now;
                        obj.Status      = 0;
                        obj.PersonId    = data.req.globalID;
                        db.tEducationalBackgrounds.Add(obj);
                        db.SaveChanges();
                    }
                }


                if (data.req.EmpArr != null)
                {
                    var obj2 = new tEmploymentHistory();
                    foreach (var a in data.req.EmpArr)
                    {
                        obj2.CompanyName    = a.CompanyName;
                        obj2.CompanyAddress = a.CompanyAddress;
                        obj2.Position       = a.Position;
                        obj2.StartedDate    = a.StartedDate;
                        obj2.EndedDate      = a.EndedDate;
                        obj2.DateCreated    = DateTime.Now;
                        obj2.PersonId       = data.req.globalID;
                        obj2.Status         = 0;
                        db.tEmploymentHistories.Add(obj2);
                        db.SaveChanges();
                    }
                }


                if (data.req.TrainArr != null)
                {
                    var obj3 = new tTraining();
                    foreach (var a in data.req.TrainArr)
                    {
                        obj3.TrainingTitle = a.TrainingTitle;
                        obj3.TrainingVenue = a.TrainingVenue;
                        obj3.Description   = a.Description;
                        obj3.PersonId      = data.req.globalID;
                        obj3.Date          = a.Date;
                        obj3.DateCreated   = DateTime.Now;
                        obj3.Status        = 0;
                        db.tTrainings.Add(obj3);
                        db.SaveChanges();
                    }
                }

                if (data.profTempArr != null)
                {
                    byte[] bitimage = Convert.FromBase64String(data.req.img.ToString());
                    data.profTempArr.ProfileImg  = bitimage;
                    data.profTempArr.PersonId    = Guid.NewGuid().ToString("N").Substring(0, 5).ToUpper();
                    data.profTempArr.DateCreated = DateTime.Now;
                    data.profTempArr.Status      = 0;
                    data.profTempArr.UserId      = data.req.globalID;
                    db.tPersonInfoes.Add(data.profTempArr);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            return(Json(data));
        }