public HttpResponseMessage TrainerSignUp([FromBody] Trainer model)
        {
            try
            {
                LearnTodayWenAPIContext con = new LearnTodayWenAPIContext();

                con.Trainers.Add(model);
                con.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.Created, model));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, e));
            }
        }
Пример #2
0
 public HttpResponseMessage PostStudent([FromBody] Student model)
 {
     try
     {
         using (LearnTodayWenAPIContext context = new LearnTodayWenAPIContext())
         {
             context.Students.Add(model);
             context.SaveChanges();
             return(Request.CreateResponse(HttpStatusCode.Created, model));
         }
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, e));
     }
 }
 public HttpResponseMessage UpdatePassword(int id, [FromBody] Trainer model)
 {
     try
     {
         LearnTodayWenAPIContext c = new LearnTodayWenAPIContext();
         Trainer t = c.Trainers.FirstOrDefault(x => x.TrainerId == id);
         if (t != null)
         {
             t.Password = model.Password;
             c.SaveChanges();
             return(Request.CreateResponse(HttpStatusCode.OK, "Data Updated Successfully"));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.NotFound, "Searched Data not Found"));
         }
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, e));
     }
 }
Пример #4
0
 public HttpResponseMessage DeleteStudentEnrollment(int id)
 {
     try
     {
         using (LearnTodayWenAPIContext co = new LearnTodayWenAPIContext())
         {
             var s = co.Students.FirstOrDefault(x => x.EnrollementId == id);
             if (s != null)
             {
                 co.Students.Remove(s);
                 co.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, "Deleted successfully"));
             }
             else
             {
                 return(Request.CreateResponse(HttpStatusCode.NotFound, "No Enrollement information found"));
             }
         }
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, e));
     }
 }