public async Task <int> SearchUserAsync() { var reader = new StreamReader(Request.Body); var body = await reader.ReadToEndAsync(); MongodbModel model = new MongodbModel(); Account account = JsonConvert.DeserializeObject <Account>(body); var hashedPassword = Crypto.HashPassword(account.password); var document = new BsonDocument { { "email", account.email }, { "password", hashedPassword } }; if (await model.insertUserAsync(document) == 1) { return(1); } if (await model.insertUserAsync(document) == 0) { return(0); } else { return(2); } }
public async Task <string> ShowProductsAsync() { MongodbModel model = new MongodbModel(); var products = await model.getAllProducts(); Console.WriteLine(products); return(JsonConvert.SerializeObject(products)); }
public async Task <string> searchAsync() { var query = Request.Query["q"]; MongodbModel model = new MongodbModel(); var products = await model.findProduct(query); Console.WriteLine(products); return(JsonConvert.SerializeObject(products)); }
public async Task <string> FetchProduct() { var reader = new StreamReader(Request.Body); var body = await reader.ReadToEndAsync(); MongodbModel model = new MongodbModel(); Edit account = JsonConvert.DeserializeObject <Edit>(body); return(await model.findProductByMatriculeAsync(account.matricule)); }
public async Task <int> ajoutProduitAsync() { var reader = new StreamReader(Request.Body); var body = await reader.ReadToEndAsync(); System.Diagnostics.Debug.Write(body); MongodbModel model = new MongodbModel(); return(await model.ajoutProduit(body)); }
public async Task <string> DeleteProduct() { var reader = new StreamReader(Request.Body); var body = await reader.ReadToEndAsync(); MongodbModel model = new MongodbModel(); Product product = JsonConvert.DeserializeObject <Product>(body); return(await model.deleteProduct(product.matricule)); }
public async Task <string> editProduct() { var reader = new StreamReader(Request.Body); var body = await reader.ReadToEndAsync(); MongodbModel model = new MongodbModel(); Account account = JsonConvert.DeserializeObject <Account>(body); return(await model.editAccount(account)); }
public async Task <bool> GetStringAsync() { var reader = new StreamReader(Request.Body); var body = await reader.ReadToEndAsync(); MongodbModel model = new MongodbModel(); Account account = JsonConvert.DeserializeObject <Account>(body); bool check = await model.loginCheck(account.email, account.password); if (check) { return(true); } else { return(false); } }
public async Task <string> editProduct() { var reader = new StreamReader(Request.Body); var body = await reader.ReadToEndAsync(); MongodbModel model = new MongodbModel(); Product product = JsonConvert.DeserializeObject <Product>(body); model.editProduct(product); return(body); // Product product = JsonConvert.DeserializeObject<Product>(body); // var document = new BsonDocument // { // { "email", product.email }, // { "prix", product.prix }, // {"quantite",product.quantite}, // {"image",product.image}, // {"matricule",product.matricule}, // {"_id", new BsonObjectId(ObjectId.Parse(product.Id))} // }; // Console.WriteLine(document); // return await model.editProduct(product, document); }
public async Task <int> GetCountGet() { MongodbModel model = new MongodbModel(); return(await model.countDocs()); }