Exemplo n.º 1
0
        [HttpPut] //api/Vendor/VendorId
        public IHttpActionResult UpdateVendor([FromUri] int id, [FromBody] Vendor updated)
        {
            MyFoodiesEntities ent;

            try
            {
                if (id == updated.VendorId)
                {
                    ent = new MyFoodiesEntities();
                    Vendor v = ent.Vendors.Find(id);
                    v.VenderName     = updated.VenderName;
                    v.VendorLocation = updated.VendorLocation;
                    v.VendorAddress  = updated.VendorAddress;
                    v.VendorMobileNo = updated.VendorMobileNo;
                    v.RestaurantName = updated.RestaurantName;
                    ent.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok(new { Name = updated.VenderName, Email = updated.VendorEmailId }));
        }
Exemplo n.º 2
0
        [HttpPut] //api/Customer/CustomerId
        public IHttpActionResult UpdateCustomer([FromUri] int id, [FromBody] Customer updated)
        {
            MyFoodiesEntities ent;

            try
            {
                if (id == updated.CustomerId)
                {
                    ent = new MyFoodiesEntities();
                    Customer c = ent.Customers.Find(id);
                    c.CustomerName     = updated.CustomerName;
                    c.CustomerMobileNo = updated.CustomerMobileNo;
                    c.CustomerAddress  = updated.CustomerAddress;
                    c.CustomerLocation = updated.CustomerLocation;
                    ent.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok(new { Name = updated.CustomerName, Email = updated.CustomerEmailId }));
        }
Exemplo n.º 3
0
        [HttpPost] //api/Customer/
        public IHttpActionResult RegisterCustomer([FromBody] Customer user)
        {
            MyFoodiesEntities ent;

            try {
                ent = new MyFoodiesEntities();
                ent.Customers.Add(user);
                ent.SaveChanges();
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Created("Created SuccessFully", new { Name = user.CustomerName, Email = user.CustomerEmailId }));
        }
Exemplo n.º 4
0
        [HttpPost] //api/Vendor/
        public IHttpActionResult AddFoodItem([FromBody] FoodItem food)
        {
            MyFoodiesEntities ent;

            try
            {
                ent = new MyFoodiesEntities();
                ent.FoodItems.Add(food);
                ent.SaveChanges();
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Created("Created SuccessFully", new { msg = "Food Added Successfully." }));
        }
Exemplo n.º 5
0
        [HttpPost] //api/Customer/placeorder
        public IHttpActionResult PlaceCustomerOrder([FromBody] Order orderdata)
        {
            MyFoodiesEntities ent;

            try
            {
                ent = new MyFoodiesEntities();
                ent.Orders.Add(orderdata);
                ent.SaveChanges();
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Created("Created SuccessFully", new { msg = "success" }));
        }
Exemplo n.º 6
0
        [HttpDelete]//api/Vendor/Foodid
        public IHttpActionResult DeleteMenuItem([FromUri] int id)
        {
            MyFoodiesEntities ent = new MyFoodiesEntities();

            try
            {
                FoodItem food = ent.FoodItems.Find(id);

                if (food != null)
                {
                    ent.FoodItems.Remove(food);
                    ent.SaveChanges();
                    return(Ok(new { msg = "Deleted Successfully" }));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Exemplo n.º 7
0
        [HttpPut] //api/Vendor/updateFood/foodid
        public IHttpActionResult UpdateMenuItem([FromUri] int id, [FromBody] FoodItem updated)
        {
            MyFoodiesEntities ent;

            try
            {
                if (id == updated.FoodId)
                {
                    ent = new MyFoodiesEntities();
                    ent.Entry(updated).State = System.Data.Entity.EntityState.Modified;
                    ent.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok(new { FoodName = updated.FoodName }));
        }