public IHttpActionResult Postgsf_Travel_Allowance(gsf_Travel_Allowance gsf_travel_allowance)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.gsf_Travel_Allowance.Add(gsf_travel_allowance);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = gsf_travel_allowance.Allowance_ID }, gsf_travel_allowance);
        }
        // PUT api/Default2/5
        public IHttpActionResult Putgsf_Travel_Allowance(int id, gsf_Travel_Allowance gsf_travel_allowance)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != gsf_travel_allowance.Allowance_ID)
            {
                return BadRequest();
            }

            db.Entry(gsf_travel_allowance).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!gsf_Travel_AllowanceExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
 public string Getgsf_Travel_Allowance(string query, string para)
 {
     if (query == "checkrecordexist")
     {
         var termcode = getTermCode();
         var recordnumber = (from m in db.gsf_Travel_Allowance
                             where m.USC_ID == para & m.Period_Code == termcode
                             select m.USC_ID).Count();
         return recordnumber.ToString();
     }
     else if (query == "createnewapplication")
     {
         string[] words = para.Split('$');
         var USC_ID =words[0];
         var Applicant_ID=words[1];
         var USC_Email=words[2];
         var Period_Code=words[3];
         var Start_Apply_Time=words[4];
         gsf_Travel_Allowance gsf_travel_allowance =new gsf_Travel_Allowance();
         gsf_travel_allowance.USC_ID=USC_ID;
         gsf_travel_allowance.Applicant_ID=Convert.ToInt32(Applicant_ID);
         gsf_travel_allowance.USC_Email=USC_Email;
         gsf_travel_allowance.Period_Code=Convert.ToInt32(Period_Code);
         Random r = new Random();
         var x = r.Next(0, 100000);
         string s = x.ToString("00000");
         gsf_travel_allowance.PIN=s;
         gsf_travel_allowance.Apply_Status=0;
         gsf_travel_allowance.Admin_Status=0;
         gsf_travel_allowance.Is_Email_Sent = 0;
         gsf_travel_allowance.Start_Apply_Time=Convert.ToDateTime(Start_Apply_Time);
         Postgsf_Travel_Allowance(gsf_travel_allowance);
         return "created";
     }
     else if (query == "getseveraladminstatus")
     {
         string[] words = para.Split('@');
         var word0 = words[0];
         var word1 = words[1];
         var table = from m in db.gsf_Travel_Allowance
                     where m.USC_ID == word0 & m.Period_Code.ToString() == word1
                     select new { Admin_Status = m.Admin_Status };
         var count = table.Count();
         if (count != 0)
         {
             foreach (var c in table)
             {
                 return c.Admin_Status.ToString();
             }
         }
         else
         {
             return "-1";
         }
     }
     else if (query == "getstartapplytime")
     {
         var termcode = getTermCode();
         var table = from m in db.gsf_Travel_Allowance
                     where m.USC_ID == para & m.Period_Code == termcode
                     select new { StartApplyTime = m.Start_Apply_Time };
         var count = table.Count();
         if (count != 0)
         {
             foreach (var c in table)
             {
                 return c.StartApplyTime.ToString();
             }
         }
         else
         {
             return null;
         }
     }
     else if (query == "getpin")
     {
         var termcode = getTermCode();
         var getpin = from m in db.gsf_Travel_Allowance
                      where m.USC_ID == para & m.Period_Code == termcode
                      select new { PIN = m.PIN };
         if (getpin.Count() != 0)
         {
             return "exist";
         }
         else
             return null;
     }
     else if (query == "getentryforapplicant")
     {
         var termcode = getTermCode();
         var row = from m in db.gsf_Travel_Allowance
                   where m.USC_ID == para & m.Period_Code == termcode
                   select new { IsPassScreening = m.Pass_Screening, IsCompleteUnits = m.Complete_Units, ChairFName = m.Chair_FName, ChairLName = m.Chair_LName, ChairEmail = m.Chair_Email, AdvisorFName = m.Advisor_FName, AdvisorLName = m.Advisor_LName, AdvisorEmail = m.Advisor_Email, Purpose = m.Travel_Purpose };
         foreach (var c in row)
         {
             return c.IsPassScreening + "&" + c.IsCompleteUnits + "&" + c.ChairFName + "&" + c.ChairLName + "&" + c.ChairEmail + "&" + c.AdvisorFName + "&" + c.AdvisorLName + "&" + c.AdvisorEmail + "&" + c.Purpose;
         }
     }
     else if (query == "getentrynumberforapplicant")
     {
         var termcode = getTermCode();
         var rownumber = (from m in db.gsf_Travel_Allowance
                          where m.USC_ID == para & m.Period_Code == termcode
                          select m.USC_Email).Count();
         return rownumber.ToString();
     }
     else if (query == "getallowanceid")
     {
         var termcode = getTermCode();
         var row = from m in db.gsf_Travel_Allowance
                   where m.USC_ID == para & m.Period_Code == termcode
                   select new { AppId = m.Allowance_ID };
         foreach (var c in row)
         {
             return c.AppId.ToString();
         }
     }
     else if (query == "getapplystate")
     {
         var termcode = getTermCode();
         var row = from m in db.gsf_Travel_Allowance
                   where m.USC_ID == para & m.Period_Code == termcode
                   select new { AppId = m.Apply_Status };
         foreach (var c in row)
         {
             return c.AppId.ToString();
         }
     }
     else if (query == "getseveralallowanceid")
     {
         //var termcode = getTermCode();
         string[] words = para.Split('@');
         var word0 = words[0];
         var word1 = words[1];
         var row = from m in db.gsf_Travel_Allowance
                   where m.USC_ID == word0 & m.Period_Code.ToString() == word1
                   select new { AppId = m.Allowance_ID };
         foreach (var c in row)
         {
             return c.AppId.ToString();
         }
     }
     else if (query == "getallinformation")
     {
         // var termcode = getTermCode();
         var row = from m in db.gsf_Travel_Allowance
                   where m.Allowance_ID.ToString() == para
                   select m;
         foreach (var c in row)
         {
             return c.Allowance_ID + "$" + c.Period_Code + "$" + c.USC_ID + "$" + c.USC_Email + "$" + c.PIN + "$" + c.Travel_Destination + "$" + c.Travel_Purpose + "$" + c.Travel_Comment + "$" + c.Chair_FName + "$" + c.Chair_LName + "$" + c.Chair_Email + "$" + c.Advisor_FName + "$" + c.Advisor_LName + "$" + c.Advisor_Email + "$" + c.Apply_Status + "$" + c.Admin_Status + "$" + c.Is_Email_Sent + "$" + c.Decision_Notes + "$" + c.Start_Apply_Time + "$" + c.Last_Update_Time + "$" + c.Submit_Time + "$" + c.Start_Review_Time + "$" + c.Approve_Time + "$" + c.Decline_Time + "$" + c.Email_Sent_Time + "$" + c.Pass_Screening + "$" + c.Complete_Units + "$" + c.Applicant_ID + "$" + c.AllowanceAmount;
         }
     }
     else if (query == "getdetailinformation")
     {
         var row = from m in db.gsf_Travel_Allowance
                   join n in db.vw_Active_Travel_Grant_Students on m.Applicant_ID equals n.Applicant_ID
                   where m.Allowance_ID.ToString() == para
                   select new { n.LastName, n.FirstName, m.USC_ID, m.USC_Email, n.Program, n.School, n.Fellowship_Name, n.Term_ID, n.Post, m.Period_Code, m.Travel_Purpose, m.Chair_FName, m.Chair_LName, m.Chair_Email, m.Advisor_FName, m.Advisor_LName, m.Advisor_Email, m.Pass_Screening, m.Complete_Units };
         foreach (var c in row)
         {
             return c.LastName + "$" + c.FirstName + "$" + c.USC_ID + "$" + c.USC_Email + "$" + c.Program + "$" + c.School + "$" + c.Fellowship_Name + "$" + Convert.ToInt32(c.Term_ID / 10) + "$" + c.Post + "$" + c.Travel_Purpose + "$" + c.Period_Code + "$" + c.Advisor_FName + " " + c.Advisor_LName + "$" + c.Advisor_Email + "$" + c.Chair_FName + " " + c.Chair_LName + "$" + c.Chair_Email + "$" + c.Pass_Screening + "$" + c.Complete_Units;
         }
     }
     else if (query == "getadmindetailinformation")
     {
         var row = from m in db.gsf_Travel_Allowance
                   join n in db.vw_Active_Travel_Grant_Students on m.Applicant_ID equals n.Applicant_ID
                   where m.Allowance_ID.ToString() == para
                   select new { m.Period_Code, m.Is_Email_Sent, m.Admin_Status, m.Decision_Notes, m.AllowanceAmount };
         foreach (var c in row)
         {
             return c.Is_Email_Sent + "$" + c.Period_Code + "$" + c.Admin_Status + "$" + c.Decision_Notes + "$" + c.AllowanceAmount;
         }
     }
     return "unsolved";
 }