public dynamic Get(int _id, [FromBody] string _password) { try { ClothesShopDBConnection db = new ClothesShopDBConnection(); Client c = db.Clients.SingleOrDefault(x => x.id == _id); if (c != null) { ClientDTO logClient = new ClientDTO() { id = c.id, name = c.name, password = c.password, is_admin = c.is_admin }; return(logClient); } else { return(null); } } catch (Exception) { return(null); } }
public void Post(Clothe value) { ClothesShopDBConnection DB = new ClothesShopDBConnection(); DB.Clothes.Add(value); DB.SaveChanges(); }
public dynamic Get(int _id) { ClothesShopDBConnection db = new ClothesShopDBConnection(); List <PurchaseDTO> orders = db.Purchases.Where(x => x.client_id == _id).Select(x => new PurchaseDTO() { client_id = x.client_id, clothe_number = x.clothe_number, purchase_date = x.purchase_date, amount = x.amount, purchase_id = x.purchase_id }).ToList(); return(orders); }
[Route("api/Clothe")] // הוספת בגד חדש לdb public dynamic Get() // משיכת כל הבגדים הפעילים { ClothesShopDBConnection db = new ClothesShopDBConnection(); return(db.Clothes.Where(c => c.is_active == true).Select(x => new ClotheDTO() { number = x.number, details = x.details, cosumer_price = x.cosumer_price, amount_in_stock = x.amount_in_stock, category = x.category, img_url = x.img_url }).ToList()); }
// GET api/<controller> //public IEnumerable<string> Get() //{ // return new string[] { "value1", "value2" }; //} public dynamic Get() { ClothesShopDBConnection db = new ClothesShopDBConnection(); return(db.Clothes.Where(c => c.is_active == true).Select(x => new ClotheDTO() { number = x.number, details = x.details, priceSupp = x.cosumer_price, priceBuyer = x.cost_price, stock = x.amount_in_stock, category = x.category, img_url = x.img_url }).ToList()); }
public dynamic Put(int _id, [FromBody] string _password) { Console.WriteLine(" HELLO !!!!!"); ClothesShopDBConnection db = new ClothesShopDBConnection(); Client c = db.Clients.SingleOrDefault(x => x.id == _id); Console.WriteLine("before if"); if (c != null && c.password == _password) { Console.WriteLine("in the if"); ClientDTO logClient = new ClientDTO() { id = c.id, name = c.name, password = c.password }; return(logClient); } else { return(null); } }