public HttpResponseMessage DeleteUser(int id) { using (OnlineEntities2 obj = new OnlineEntities2()) { var data = obj.Registrations.FirstOrDefault(x => x.ID == id); data.IsDeleted = "False"; obj.SaveChanges(); obj.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Added")); } }
public HttpResponseMessage AddUser(Registration data) { using (OnlineEntities2 obj = new OnlineEntities2()) { obj.Registrations.Add(data); obj.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Added")); } }
public HttpResponseMessage EditUser([FromBody] Registration data) { using (OnlineEntities2 obj = new OnlineEntities2()) { Registration user = obj.Registrations.FirstOrDefault(x => x.ID == data.ID); if (user != null) { user.Name = data.Name; user.PassWord = data.PassWord; obj.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Edited")); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "User not found")); } } }