public Response <string> EditDeal(int id, Deal Dl) { Response <string> res = new Response <string>(); try { using (var dbContext = new MenuAppDBEntities3()) { dbContext.Deals.First(o => o.DealId == id).Equals(Dl); dbContext.SaveChanges(); } res.IsError = false; res.Data = "Everything is fine"; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; res.Data = "Everything is not fine"; } return(res); }
public Response <string> DeleteDeal(int id) { Response <string> res = new Response <string>(); try { res.IsError = false; res.Data = "Item Deleted"; res.ErrorDetails = "Null"; using (var dbContext = new MenuAppDBEntities3()) { var DeletedDeal = dbContext.Deals.Where(o => o.DealId == id).First(); dbContext.Deals.Remove(DeletedDeal); dbContext.SaveChanges(); } } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; res.Data = "Item Not Deleted"; } return(res); }
public Response <List <Deal> > GetDeals(int id) { Response <List <Deal> > res = new Response <List <Deal> >(); try { List <Deal> _Deals; using (var dbContext = new MenuAppDBEntities3()) { _Deals = dbContext.Deals.Where(o => o.CompanyId == id).ToList(); } res.IsError = false; res.Data = _Deals; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }
public Response <Deal> GetDeals(int id, int companyId) { Response <Deal> res = new Response <Deal>(); try { Deal _Deal; using (var dbContext = new MenuAppDBEntities3()) { _Deal = dbContext.Deals.Where(o => o.DealId == id).First(); } res.IsError = false; res.Data = _Deal; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }
public Response <string> AddCompany(Company cmpn) { Response <string> res = new Response <string>(); try { using (var dbContext = new MenuAppDBEntities3()) { dbContext.Companies.Add(cmpn); dbContext.SaveChanges(); } res.IsError = false; res.Data = "Everything is fine"; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; res.Data = "Everything is not fine"; } return(res); }
public Response <string> /*??*/ AddProduct(Product prod) { Response <string> res = new Response <string>(); try { using (var dbContext = new MenuAppDBEntities3()) { dbContext.Products.Add(prod); dbContext.SaveChanges(); } res.IsError = false; res.Data = "Everything is fine"; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; res.Data = "Everything is not fine"; } return(res); }
public Response <Company> GetCompanies(string name) { Response <Company> res = new Response <Company>(); try { Company _Company; using (var dbContext = new MenuAppDBEntities3()) { _Company = dbContext.Companies.First(o => o.Name == name);; } res.IsError = false; res.Data = _Company; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }
public Response <Company> GetCompanies(int id, int companyId) { Response <Company> res = new Response <Company>(); try { Company _Company; using (var dbContext = new MenuAppDBEntities3()) { _Company = dbContext.Companies.Where(o => o.CompanyId == id).First(); } res.IsError = false; res.Data = _Company; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }
public Response <List <Company> > GetCompanies() { Response <List <Company> > res = new Response <List <Company> >(); try { List <Company> _Companies; using (var dbContext = new MenuAppDBEntities3()) { _Companies = dbContext.Companies.ToList(); } res.IsError = false; res.Data = _Companies; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }
public Response <Branch> GetBranches(int id, int companyId) { Response <Branch> res = new Response <Branch>(); try { Branch _branch; using (var dbContext = new MenuAppDBEntities3()) { _branch = dbContext.Branches.Where(o => o.BranchId == id).First(); } res.IsError = false; res.Data = _branch; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }
public Response <string> EditSale(int id, Sale Sale) { Response <string> res = new Response <string>(); try { using (var dbContext = new MenuAppDBEntities3()) { dbContext.Sales.Where(o => o.SaleId == id).Equals(Sale); } res.IsError = false; res.Data = "Everything is fine"; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; res.Data = "Everything is not fine"; } return(res); }
public Response <List <Product> > GetProducts() { Response <List <Product> > res = new Response <List <Product> >(); try { using (var dbContext = new MenuAppDBEntities3()) { res.Data = dbContext.Products.ToList(); } res.IsError = false; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }
public Response <Product> GetProducts(int id) { Response <Product> res = new Response <Product>(); try { using (var dbContext = new MenuAppDBEntities3()) { res.Data = dbContext.Products.FirstOrDefault(o => o.ProductId == id); } res.IsError = false; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }
public Response <List <Sale> > GetSales(int id) { Response <List <Sale> > res = new Response <List <Sale> >(); try { using (var dbContext = new MenuAppDBEntities3()) { res.Data = dbContext.Sales.Where(o => o.ProductID == id).ToList(); } res.IsError = false; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }
public Response <bool> GetIsOnSale(int id) { Response <bool> res = new Response <bool>(); try { using (var dbContext = new MenuAppDBEntities3()) { res.Data = dbContext.Sales.First(o => o.SaleId == id).IsOnSale; } res.IsError = false; res.ErrorDetails = "Null"; } catch (Exception ex) { res.IsError = true; res.ErrorDetails = ex.Message; } return(res); }