public async Task <HttpResponseMessage> Addfavourite(string email, string MovieID, string MovieTitle, string MovieYear) { List <string> request_response = new List <string> { }; //Response creator Response response = new Response(); //To check if the provided user email is present in DB RegistrationRepository regrep = new RegistrationRepository(); var checkuser = await regrep.CheckUserExistance(email); //If the user is not present in DB if (checkuser.Count() == 0) { response.responsecode = false; response.responsemessage.Add("Cannot add favourite as the provided email doesnot exist"); return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"))); } //If user is present in DB else { var register = await favouriteRepository.Addfavourite(email, MovieID, MovieTitle, MovieYear); response.responsecode = register; response.responsemessage.Add("Favourite added Successfully"); return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"))); } }
public async Task <HttpResponseMessage> UserRegistration(string email, string password) { //Response creator Response response = new Response(); try { List <string> request_response = new List <string> { }; Register reg = new Register(); reg.email = email; reg.password = password; //to check if user already exist in DB RegistrationRepository regrep = new RegistrationRepository(); var checkuser = await regrep.CheckUserExistance(email, password); //If user doesnot exist in DB if (checkuser.Count() == 0) { try { MailAddress m = new MailAddress(email); var register = await registrationRepository.User_Registration(email, password); response.responsecode = register; response.responsemessage.Add("User Registration is Succcessful"); return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"))); } catch (FormatException a) { response.responsecode = false; response.responsemessage.Add("Provided email is not in correct format"); //response.responsemessage.Add(a.ToString()); return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"))); } } //If user exist in DB else { response.responsecode = false; response.responsemessage.Add("User Already Exist"); return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"))); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message, MediaTypeHeaderValue.Parse("application/json"))); } }
public async Task <HttpResponseMessage> AddReview(string email, string MovieID, string MovieTitle, string MovieYear, string Reviews) { try { List <string> request_response = new List <string> { }; //Response Creator Response response = new Response(); //To check if the provided user email is present in DB RegistrationRepository regrep = new RegistrationRepository(); var checkuser = await regrep.CheckUserExistance(email); //If the user is not present in DB if (checkuser.Count() == 0) { response.responsecode = false; response.responsemessage.Add("Cannot add Review as the provided email doesnot exist"); //string requestJSON = JsonConvert.SerializeObject(request, Formatting.Indented); //request_response.Add("false"); //request_response.Add("Cannot add Review as the provided email doesnot exist"); //return Request.CreateResponse(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json")); return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"))); } //If user is present in DB else { var review = await reviewRepository.AddReview(email, MovieID, MovieTitle, MovieYear, Reviews); response.responsecode = review; response.responsemessage.Add("Review added Successfully"); return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"))); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message, MediaTypeHeaderValue.Parse("application/json"))); } }
public async Task <HttpResponseMessage> UserLogin(string email, string password) { //Response creator Response response = new Response(); try { List <string> request_response = new List <string> { }; Register reg = new Register(); reg.email = email; reg.password = password; //to check if user already exist in DB RegistrationRepository regrep = new RegistrationRepository(); var checkuser = await regrep.CheckUserExistance(email, password); //If user doesnot exist in DB if (checkuser.Count() == 0) { response.responsecode = false; response.responsemessage.Add("User Login Failed - User ID or Password is invalid"); return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"))); } //If user exist in DB else { response.responsecode = true; response.responsemessage.Add("User Login is Succcessful"); return(this.Request.CreateResponse <Response>(HttpStatusCode.OK, response, MediaTypeHeaderValue.Parse("application/json"))); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message, MediaTypeHeaderValue.Parse("application/json"))); } }