public ActionResult <Notes> CreateNotes(string description, string date) { ActionResult <Notes> response; Notes create; try { // We aren't concerned with validation here. Only in BLL. create = new NotesController().CreateNotes(description, date); // Encode our created object as JSON and bounce it back with the request. response = Ok(create); } catch (Exception e) { response = UnprocessableEntity(new { error = e.Message }); } // Return the response. return(response); }
public ActionResult <User> AllUsers(string email) { ActionResult <User> response; User user; try { // We aren't concerned with validation here. Only in BLL. user = new NotesController().GetUsers(email); // Encode our created object as JSON and bounce it back with the request. response = Ok(user); } catch (Exception e) { response = UnprocessableEntity(new { error = e.Message }); } // Return the response. return(response); }
public ActionResult <User> SignUp(string fname, string lname, string email, string password) { ActionResult <User> response; User created; try { // We aren't concerned with validation here. Only in BLL. created = new NotesController().SignUpbyEmail(fname, lname, email, password); // Encode our created object as JSON and bounce it back with the request. response = Ok(created); } catch (Exception e) { response = UnprocessableEntity(new { error = e.Message }); } // Return the response. return(response); }
public ActionResult <Notes> EditNotesByID(string id, string description) { ActionResult <Notes> response; Notes modified; try { // We aren't concerned with validation here. Only in BLL. modified = new NotesController().EditNotesByID(id, description); // Encode our created object as JSON and bounce it back with the request. response = Ok(modified); } catch (InvalidOperationException) { response = StatusCode(403, new { error = $"No description was found with the ID of {id}." }); } catch (Exception e) { response = StatusCode(403, new { error = e.Message }); } // Return the response. return(response); }