コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }