public cake CreateCake(string name, int price, string details) { cake cake = new cake() { Id = idCount, Name = name, Price = price, Details = details }; idCount++; cakes.Add(cake); return(cake); }
public cake CreateCake(string name, int price, string details) { cake cake = new cake() { Name = name, Price = price, Details = details }; _cakeDBContext.Caked.Add(cake); _cakeDBContext.SaveChanges(); return(cake); }
public bool DeleteCake(int id) { bool wasRemoved = false; cake cake = _cakeDBContext.Caked.SingleOrDefault(caked => caked.Id == id); if (cake == null) { return(wasRemoved); } _cakeDBContext.Caked.Remove(cake); _cakeDBContext.SaveChanges(); return(wasRemoved); }
public bool UpdateCake(cake cake) { bool wasUpdated = false; foreach (cake orginal in cakes) { if (orginal.Id == cake.Id) { orginal.Name = cake.Name; orginal.Price = cake.Price; orginal.Details = cake.Details; wasUpdated = true; break; } } return(wasUpdated); }
public bool UpdateCake(cake cake) { bool wasUpdated = false; cake orginal = _cakeDBContext.Caked.SingleOrDefault(Caked => Caked.Id == cake.Id); if (orginal != null) { orginal.Name = cake.Name; orginal.Price = cake.Price; orginal.Details = cake.Details; _cakeDBContext.SaveChanges(); wasUpdated = true; } return(wasUpdated); }