public ActionResult ApplyLeave(LeaveDetail leaveDetail)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (StudentEntities2 re = new StudentEntities2())
             {
                 leaveDetail.PersonId   = Convert.ToInt32(Session["PersonId"]);
                 leaveDetail.PersonName = Convert.ToString(Session["PersonName"]);
                 if (Convert.ToInt32(Session["Role"]) == 3)
                 {
                     leaveDetail.IsStudent = true;
                 }
                 else
                 {
                     leaveDetail.IsStudent = false;
                 }
                 leaveDetail.LeaveStatus = 1;
                 re.LeaveDetails.Add(leaveDetail);
                 re.SaveChanges();
                 ModelState.Clear();
                 ViewBag.Message = "Success";
                 leaveDetail     = null;
             }
         }
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "Student", "Index")));
     }
     return(View(leaveDetail));
 }
        public IHttpActionResult create(stud_Details s)
        {
            StudentEntities2 obj = new StudentEntities2();

            obj.stud_Details.Add(s);
            obj.SaveChanges();
            return(Ok("successfull"));
        }
        public IHttpActionResult delete(int id)
        {
            StudentEntities2 obj = new StudentEntities2();
            var del = (from b in obj.stud_Details where b.ID == id select b).FirstOrDefault();

            obj.stud_Details.Remove(del);
            obj.SaveChanges();
            return(Ok(" Delete Sucessfull"));
        }
Esempio n. 4
0
        public stud_Details generatetoken(string name, string password)
        {
            string   token     = Guid.NewGuid().ToString();
            DateTime issuedOn  = DateTime.Now;
            DateTime expiredOn = DateTime.Now.AddSeconds(50000000);
            var      tokd      = new stud_Details
            {
                Expiry   = expiredOn,
                Token    = token,
                UserName = name
            };
            StudentEntities2 obj = new StudentEntities2();

            obj.stud_Details.Add(tokd);
            obj.SaveChanges();
            return(tokd);
        }