public HttpResponseMessage Post([Bind(Include = "Email,Model")] StudentViewModel svm) { AssignmentManagementSystemEntities db = new AssignmentManagementSystemEntities(); string message = "Student Added Successfully"; bool isexists = stuDB.EmailExists(svm.Email); if (isexists) { ModelState.AddModelError("Email", "Email Already Exist"); } if (ModelState.IsValid) { // stuDB.Add(svm); //stuDB.SendSMS(); tblStudent tb = db.tblStudents.Where(x => x.Email == svm.Email).FirstOrDefault(); if (tb != null) { stuDB.SendEMail(tb.Student_Id); } //tblStudent tb1 = db.tblStudents.Where(x => x.Phone == svm.Phone).FirstOrDefault(); //if (tb1 != null) //{ // stuDB.SendSMS(tb1.Phone); //} return(Request.CreateResponse(HttpStatusCode.OK, message)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }