示例#1
0
        protected void lnk_View_Click(object sender, EventArgs e)
        {
            int           restId     = Convert.ToInt32((sender as LinkButton).CommandArgument);
            RestaurantBLL rBLL       = new RestaurantBLL();
            Restaurant    restaurant = rBLL.DoRetrieveRestaurantByRestID(restId);

            txtRName.Text = restaurant.RestName;

            DataTable dt       = new DataTable();
            PromoBLL  promoBLL = new PromoBLL();

            dt = promoBLL.DoRetrieveAllPromoByRestId(restId);

            panelViewPromo.Visible = true;

            if (dt != null)
            {
                gv_promo.DataSource = dt;
                gv_promo.DataBind();
            }

            else
            {
                alertFailure.Visible  = true;
                lblErrorRetrieve.Text = "Error in retrieving food item list";
            }
        }
示例#2
0
        public async Task <IActionResult> PutRestaurant([FromBody] Restaurant restaurant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                RestaurantBLL BLL = new RestaurantBLL(_context);

                return(Ok(await BLL.UpdateRestaurant(restaurant)));
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!RestaurantExists(restaurant.Id))
                {
                    return(NotFound());
                }
                else
                {
                    return(BadRequest(ex.Message));
                }
            }
        }
示例#3
0
        public ActionResult FoodItemCreate(FoodItem iFoodItem)
        {
            if (ModelState.IsValid)
            {
                // Instantiates objects
                RestaurantBLL    lRestaurantBLL    = new RestaurantBLL();
                RestaurantMapper lRestaurantMapper = new RestaurantMapper();

                // map Model object to database object
                FoodItemDBO lFoodItemDBO = lRestaurantMapper.MapModelToDBO(iFoodItem);

                // get a unique food item id as return value
                int lFoodItemIDPK = lRestaurantBLL.CreateFoodItem(lFoodItemDBO);

                // success
                if (lFoodItemIDPK > 0)
                {
                    return(Json(new { success = true, blank = "" }));
                }
            }
            else
            {
                // check errors
                //var errors = ModelState.Values.SelectMany(v => v.Errors);
            }

            return(Json(new { success = false }));
        }
示例#4
0
        protected void lnk_ViewStaff_Click(object sender, EventArgs e)
        {
            int           restId     = Convert.ToInt32((sender as LinkButton).CommandArgument);
            RestaurantBLL rBLL       = new RestaurantBLL();
            Restaurant    restaurant = rBLL.DoRetrieveRestaurantByRestID(restId);

            StaffBLL  staffBLL = new StaffBLL();
            DataTable dt       = new DataTable();

            panelViewStaff.Visible = true;

            lblRestName.Text = restaurant.RestName;
            dt = staffBLL.DoRetrieveStaffByRestID(restId);

            if (dt != null)
            {
                gv_viewStaff.DataSource = dt;
                gv_viewStaff.DataBind();
            }

            else
            {
                alertFailure.Visible  = true;
                lblErrorRetrieve.Text = "Error in retrieving staff list";
            }
        }
示例#5
0
        public ActionResult UserProfile(int id, Common notice)
        {
            // Instantiate objects
            UserBLL         lUserBLL         = new UserBLL();
            UserMapper      lUserMapper      = new UserMapper();
            BoardBLL        lBoardBLL        = new BoardBLL();
            RestaurantBLL   lRestaurantBLL   = new RestaurantBLL();
            BoardCommentBLL lBoardCommentBLL = new BoardCommentBLL();

            // Instantiate object to hold all info about user
            UserRestaurantBoardUtil lUserAllData = new UserRestaurantBoardUtil();

            // Get info about user with id
            lUserAllData.UserData = lUserBLL.FindUserByID(id);

            // Get info about board with user id
            lUserAllData.BoardList        = lBoardBLL.GetAllBoardsByUserID(id);
            lUserAllData.BoardCommentList = lBoardCommentBLL.GetAllCommentsByUserID(id);

            // Get info about order with user id
            lUserAllData.OrderList = lRestaurantBLL.GetAllOrdersByUserID(id);

            // number of rows per page
            lUserAllData.PageSize = 10;


            return(View(lUserAllData));
        }
示例#6
0
        public Result Logout(MODEL.Criteria.reqTable req)
        {
            Result result = new Result();

            result.ResultOk = "false";
            RestaurantBLL sv = new RestaurantBLL();

            DAL.Restaurant svDAL = new DAL.Restaurant();
            //DAL.StringCipher sv = new DAL.StringCipher();
            try
            {
                ///Check User
                Result UserComplete = svDAL.checkOrderNotComplete(req.userID);
                if (UserComplete.ResultOk == "true")
                {
                    result.ResultOk      = "false";
                    result.ErrorMessage  = "User not pay !!!";
                    result.ReturnMessage = "";
                    return(result);
                }

                Result CancelTable = svDAL.cancelTable(req);
                result = CancelTable;
            }
            catch (Exception e)
            {
                result.ErrorMessage  = e.Message;
                result.ResultOk      = "false";
                result.ReturnMessage = "";
            }
            return(result);
        }
示例#7
0
        public Result cancelOrder([FromBody] MODEL.Criteria.reqOrder req)
        {
            Result result = new Result();

            result.ResultOk = "false";
            RestaurantBLL sv = new RestaurantBLL();

            try
            {
                result = sv.cancelOrder(req);

                //Veriy Data
                //result.ResultOk = "Success";
                //for (int i = 0; i < req.listFood.Count; i++)
                //{
                //    result.ReturnMessage += req.listFood[i].foodID + ",";
                //}
                //if (req != null)
                //{

                //return sv.InsertMenu(req);

                //}
            }
            catch (Exception e)
            {
                result.ErrorMessage  = e.Message;
                result.ResultOk      = "false";
                result.ReturnMessage = "";
            }
            return(result);
        }
示例#8
0
        public ActionResult SendOrders(int id)
        {
            // Instantiate Object
            RestaurantBLL lRestaurantBLL = new RestaurantBLL();

            bool isSent = lRestaurantBLL.sendOrdersByRestaurantID(id);

            return(PartialView());
        }
示例#9
0
        public Result insertOrder([FromBody] MODEL.Criteria.reqOrder req)
        {
            Result result = new Result();

            result.ResultOk = "false";
            RestaurantBLL sv = new RestaurantBLL();

            try
            {
                result = sv.insertOrder(req);

                //Result OrderStatus = sv.getStatusOrder(req.restaurantID, req.tableID);
                //if (OrderStatus.ResultOk == "false")
                //{
                //    result = sv.insertOrder(req);
                //}
                //else
                //{
                //    switch (OrderStatus.ReturnMessage)
                //    {
                //        case "1":
                //            result.ResultOk = "false";
                //            result.ErroMessage = "Table is open";
                //            result.ReturnMessage = "";
                //            break;
                //        case "2":
                //            result.ResultOk = "false";
                //            result.ErroMessage = "Table is bill please";
                //            result.ReturnMessage = "";
                //            break;
                //        default:
                //            result = sv.insertOrder(req);
                //            break;
                //    }
                //}


                //Veriy Data
                //result.ResultOk = "Success";
                //for (int i = 0; i < req.listFood.Count; i++)
                //{
                //    result.ReturnMessage += req.listFood[i].foodID + ",";
                //}
                //if (req != null)
                //{

                //return sv.InsertMenu(req);

                //}
            }
            catch (Exception e)
            {
                result.ErrorMessage = e.Message;
                result.ResultOk     = "false";
            }
            return(result);
        }
示例#10
0
        public ActionResult GetTopRatedOrder(int id)
        {
            // Instantiate Object
            RestaurantBLL lRestaurantBLL = new RestaurantBLL();

            // get the list of ratings
            List <UserOrderRatingDBO> lUserOrderRating = lRestaurantBLL.GetTopRatedOrdersByRestaurantID(id);

            return(PartialView(lUserOrderRating));
        }
示例#11
0
        public ActionResult Index()
        {
            // instantiate object
            RestaurantBLL lRestaurantBLL = new RestaurantBLL();

            // Get list of restaurants
            List <RestaurantDBO> lRestaurantList = lRestaurantBLL.GetAllActiveRestaurants();

            return(View(lRestaurantList));
        }
示例#12
0
        public ActionResult RestaurantRemove(int id)
        {
            // Instantiate BLL object
            RestaurantBLL lRestaurantBLL = new RestaurantBLL();

            // get result of bool if removal succeded
            bool lResult = lRestaurantBLL.RemoveRestaurantByRestaurantID(id);

            return(RedirectToAction("RestaurantList", "Restaurant"));
        }
示例#13
0
        public PartialViewResult UserOrderDetails(int id)
        {
            // Instantiate BLL object
            RestaurantBLL lRestaurantBLL = new RestaurantBLL();

            // get list of food items for the order
            List <FoodItemDBO> lFoodItemList = lRestaurantBLL.GetAllFoodItemsByOrderID(id);

            return(PartialView("UserOrderDetails", lFoodItemList));
        }
示例#14
0
        public ActionResult RestaurantList(string searchString)
        {
            // Instantitate BLL object
            RestaurantBLL      lRestaurantBLL  = new RestaurantBLL();
            RestaurantListUtil lRestaurantUtil = new RestaurantListUtil();

            // Get the list of entrie restaurant
            lRestaurantUtil.RestaurantList = lRestaurantBLL.GetAllRestaurants(searchString);

            return(View(lRestaurantUtil));
        }
示例#15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            alertSuccess.Visible        = false;
            alertFailure.Visible        = false;
            panelChangePassword.Visible = false;
            panelWorkplace.Visible      = false;

            if (!IsPostBack)
            {
                UserAccount user = (UserAccount)Session["UserAccountObj"];
                txtSUsername.Text = user.Username;

                StaffBLL staffBLL = new StaffBLL();
                Staff    staff    = staffBLL.DoRetrieveStaffByID(user.UserId);

                if (staff != null)
                {
                    txtSName.Text = staff.StaffName;
                    if (user.UserRole.Equals("Staff"))
                    {
                        RestaurantBLL restaurantBLL = new RestaurantBLL();
                        Restaurant    restaurant    = restaurantBLL.DoRetrieveRestaurantByRestID(staff.RestId);
                        panelWorkplace.Visible = true;

                        if (restaurant != null)
                        {
                            txtRName.Text    = restaurant.RestName;
                            txtRAddress.Text = restaurant.RestAddress;
                            txtRArea.Text    = restaurant.RestArea;
                        }

                        else
                        {
                            alertFailure.Visible = true;
                            lblAlertMsg.Text     = "Unable to retrieve staff profile";
                        }
                    }
                }

                else
                {
                    txtSName.Text             = "admin";
                    txtSName.Enabled          = false;
                    btnChangePassword.Enabled = false;
                    btnDeactivate.Enabled     = false;
                    btnUpdate.Enabled         = false;
                }
            }
        }
示例#16
0
        protected void lnk_AddStaff_Click(object sender, EventArgs e)
        {
            int           restId     = Convert.ToInt32((sender as LinkButton).CommandArgument);
            RestaurantBLL rBLL       = new RestaurantBLL();
            Restaurant    restaurant = rBLL.DoRetrieveRestaurantByRestID(restId);

            panelCreateStaff.Visible = true;
            lblCreateStaff.Text      = "CREATING STAFF FOR RESTAURANT ID " + restId;
            txtRestId.Text           = restId.ToString();
            txtRName.Text            = restaurant.RestName;
        }
示例#17
0
        public ActionResult RestaurantPayment()
        {
            // Instantiate objects
            RestaurantBLL lRestaurantBLL = new RestaurantBLL();

            // Do calculations
            MeaningfulCalcUtil lCalcUtil = lRestaurantBLL.GetAllCalc();

            // return the weeks and show on the left menu bar
            return(View(lCalcUtil));
        }
示例#18
0
        protected void btn_Review_Click(object sender, EventArgs e)
        {
            Orders        od    = new Orders();
            OrdersBLL     odbll = new OrdersBLL();
            RestaurantBLL rbll  = new RestaurantBLL();

            od = odbll.DoRetrieveUserOrderDetails(int.Parse(txtOrderId.Text));
            ReviewBLL reviewBLL = new ReviewBLL();

            reviewBLL.DoCreateReview(od.OrderId, od.CId, od.RId, rbll.DoRetrieveRestIdByTransactionId(od.TransactionId), Convert.ToInt32(ddlRiderRating.SelectedValue), Convert.ToInt32(ddlRestaurantRating.SelectedValue), txtReview.Text);
            Response.Redirect("UserRetrieveReview.aspx?orderid=" + od.OrderId);
        }
示例#19
0
        protected void lnk_Update_Click(object sender, EventArgs e)
        {
            int           restId     = Convert.ToInt32((sender as LinkButton).CommandArgument);
            RestaurantBLL rBLL       = new RestaurantBLL();
            Restaurant    restaurant = rBLL.DoRetrieveRestaurantByRestID(restId);

            panelUpdateRestaurant.Visible = true;
            lblUpdateRestaurant.Text      = "Updating Record for Restaurant ID: " + restaurant.RestId;
            txtRestId.Text         = restaurant.RestId.ToString();
            txtRName.Text          = restaurant.RestName;
            txtRAddress.Text       = restaurant.RestAddress;
            ddlRArea.SelectedValue = restaurant.RestArea;
            txtMinAmnt.Text        = restaurant.MinAmnt.ToString();
        }
示例#20
0
        public ActionResult RestaurantUpdate(Restaurant iRestaurant)
        {
            if (ModelState.IsValid)
            {
                // validation for price
                if (!Decimal.TryParse(iRestaurant.SandwichPrice.ToString(), out decimal price))
                {
                    return(View(iRestaurant));
                }
                // Instantiate objects
                RestaurantBLL    lRestaurantBLL    = new RestaurantBLL();
                RestaurantMapper lRestaurantMapper = new RestaurantMapper();

                // Map Model to DB object
                RestaurantDBO lRestaurantDBO = lRestaurantMapper.MapModelToDBO(iRestaurant);

                // get result after update
                bool lResult = lRestaurantBLL.UpdateRestaurantByRestaurantID(lRestaurantDBO);

                if (lResult)
                {
                    // success
                    TempData["msg"] = "<script>alert('Successfully Updated!')</script>";
                    return(RedirectToAction("RestaurantProfile", "Restaurant", new { id = lRestaurantDBO.RestaurantIDPK }));
                }
                else
                {
                    // failure
                    TempData["msg"] = "<script>alert('Error occured while processing your request. Please try later.')</script>";
                }
            }
            else
            {
                // model state not valid
                TempData["msg"] = "<script>alert('Please Fill all Required Fields.')</script>";
            }

            // Add days to the list
            iRestaurant.DayList = new List <string>();
            iRestaurant.DayList.Add("Monday");
            iRestaurant.DayList.Add("Tuesday");
            iRestaurant.DayList.Add("Wednesday");
            iRestaurant.DayList.Add("Thursday");
            iRestaurant.DayList.Add("Friday");
            iRestaurant.DayList.Add("Saturday");
            iRestaurant.DayList.Add("Sunday");

            return(View(iRestaurant));
        }
示例#21
0
        public ActionResult RestaurantProfile(int id, string searchString)
        {
            // Instantiate objects
            RestaurantBLL    lRestaurantBLL    = new RestaurantBLL();
            RestaurantMapper lRestaurantMapper = new RestaurantMapper();

            // Instantiate util object
            RestaurantFoodsRatingUtil lRestaurantUtil = new RestaurantFoodsRatingUtil();

            // Get info about a restaurant by restaurant id
            lRestaurantUtil.Restaurant = lRestaurantBLL.FindRestaurantByRestaurantID(id);

            // Get list of food items by restaurant id
            lRestaurantUtil.FoodItemList = lRestaurantBLL.GetAllFoodItemsByRestaurantID(id);

            // check if searchstring not null
            if (!string.IsNullOrEmpty(searchString) && searchString != "reset")
            {
                lRestaurantUtil.FoodItemList = lRestaurantUtil.FoodItemList.Where(food => food.FoodItemName.ToLower().Contains(searchString) ||
                                                                                  food.FoodTypeName.ToLower().Contains(searchString) ||
                                                                                  food.IngredientTypeName.ToLower().Contains(searchString)).ToList();

                // set current tab
                ViewBag.tab = "nav-foods";
            }
            else
            {
                // if user reset search, populate food item list again
                lRestaurantUtil.FoodItemList = lRestaurantBLL.GetAllFoodItemsByRestaurantID(id);

                if (searchString == "reset")
                {
                    // set current tab
                    ViewBag.tab = "nav-foods";
                }
                else
                {
                    // set currert tab
                    ViewBag.tab = "nav-info";
                }
            }

            // Get list of rating for restaurant by id
            lRestaurantUtil.RatingList = lRestaurantBLL.GetAllRatingByRestaurantID(id);

            lRestaurantUtil.RestaurantRating = lRestaurantBLL.GetRatingAverageByRestaurantID(id);

            return(View(lRestaurantUtil));
        }
示例#22
0
        public ActionResult OrderCheck(int id)
        {
            // Restaurant BLL objects
            RestaurantBLL lRestaurantBLL = new RestaurantBLL();

            // get list of orders for the restaurant within a week
            List <UserOrderDBO> lUserOrderList = lRestaurantBLL.GetAllRecentOrdersByRestaurantID(id);

            if (lUserOrderList.Count == 0)
            {
                TempData["msg"] = "<script>alert('No orders');</script>";
                return(RedirectToAction("Index", "Restaurant"));
            }
            return(PartialView("OrderCheck", lUserOrderList));
        }
示例#23
0
        public async Task <IActionResult> DeleteRestaurant([FromRoute] int id)
        {
            try
            {
                RestaurantBLL BLL = new RestaurantBLL(_context);
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                return(Ok(await BLL.DeleteRestaurant(id)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
示例#24
0
        public ResultProfile updateProfile([FromBody] MODEL.ResultProfile req)
        {
            ResultProfile result = new ResultProfile();

            result.ResultOk = "false";
            RestaurantBLL sv = new RestaurantBLL();

            try
            {
                result = sv.updateProfile(req);
            }
            catch (Exception e)
            {
                result.ErrorMessage = e.Message;
                result.ResultOk     = "false";
            }
            return(result);
        }
示例#25
0
        public ResultRestaurantContent getFirstPage()
        {
            ResultRestaurantContent result = new ResultRestaurantContent();

            result.ResultOk = "false";
            RestaurantBLL sv = new RestaurantBLL();

            try
            {
                result = sv.getFirstPage(null);
            }
            catch (Exception e)
            {
                result.ErrorMessage = e.Message;
                result.ResultOk     = "false";
            }
            return(result);
        }
示例#26
0
        public ResultRestaurantContent getFirstPageByID(MODEL.Criteria.reqRestaurant req)
        {
            ResultRestaurantContent result = new ResultRestaurantContent();

            result.ResultOk = "false";
            RestaurantBLL sv = new RestaurantBLL();

            try
            {
                result = sv.getFirstPage(req);
            }
            catch (Exception e)
            {
                result.ErrorMessage = e.Message;
                result.ResultOk     = "false";
            }
            return(result);
        }
示例#27
0
        public ResultHistoryUser getHistoryUser(MODEL.Criteria.reqUser req)
        {
            ResultHistoryUser result = new ResultHistoryUser();

            result.ResultOk = "false";
            RestaurantBLL sv = new RestaurantBLL();

            try
            {
                result = sv.getHistoryByUserID(req);
            }
            catch (Exception e)
            {
                result.ErrorMessage = e.Message;
                result.ResultOk     = "false";
            }
            return(result);
        }
示例#28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            panelViewRestaurants.Visible  = false;
            alertSuccess.Visible          = false;
            alertFailure.Visible          = false;
            panelUpdateRestaurant.Visible = false;

            UserAccount user = (UserAccount)Session["UserAccountObj"];

            if (!IsPostBack)
            {
                DataTable     dt   = new DataTable();
                RestaurantBLL rBLL = new RestaurantBLL();
                dt = rBLL.DoRetrieveAllRestaurants();

                if (dt != null)
                {
                    gv_restaurants.DataSource = dt;
                    gv_restaurants.DataBind();
                }

                else
                {
                    alertFailure.Visible  = true;
                    lblErrorRetrieve.Text = "Error in retrieving list";
                }
            }

            if (!user.UserRole.Equals("Manager"))
            {
                lblUserDenied.Text = "YOU DO NOT HAVE MANAGER RIGHTS TO ACCESS THIS FUNCTION";
                btnSearch.Enabled  = false;
            }

            else
            {
                panelViewRestaurants.Visible = true;
            }
        }
示例#29
0
        public ActionResult RestaurantRegister(Restaurant iRestaurant)
        {
            if (ModelState.IsValid)
            {
                // Map Models.Restaurant to db objects
                RestaurantMapper lRestaurantMapper = new RestaurantMapper();
                RestaurantDBO    lRestaurantDBO    = lRestaurantMapper.MapModelToDBO(iRestaurant);

                // insert mapped object into database
                RestaurantBLL lRestaurantBLL  = new RestaurantBLL();
                int           lRestaurantIDPK = lRestaurantBLL.CreateRestaurant(lRestaurantDBO);


                if (lRestaurantIDPK > 0)
                {
                    // success
                    ViewBag.msg = "<script>alert('Registered Successfully');</script>";
                    return(RedirectToAction("RestaurantList", "Restaurant"));
                }
                else
                {
                    // failure
                    ViewBag.msg = "<script>alert('Registeration Failed');</script>";
                }
            }
            else
            {
                //not valid model state
                ViewBag.msg = "<script>alert('Not Valid Inputs');</script>";
            }

            // re-populate days to the list in case of failure
            iRestaurant.DayList = new List <string>();
            iRestaurant.DayList.Add("Monday");
            iRestaurant.DayList.Add("Tuesday");
            iRestaurant.DayList.Add("Wednesday");
            iRestaurant.DayList.Add("Thursday");
            iRestaurant.DayList.Add("Friday");
            iRestaurant.DayList.Add("Saturday");
            iRestaurant.DayList.Add("Sunday");

            return(View(iRestaurant));
        }
示例#30
0
        public ResultLogin Login([FromBody] MODEL.Criteria.reqLogin req)
        {
            ResultLogin result = new ResultLogin();

            result.ResultOk = "false";
            RestaurantBLL sv = new RestaurantBLL();

            try
            {
                result = sv.getLoginGuest(req);
            }
            catch (Exception e)
            {
                result.ErroMessage   = e.Message;
                result.ResultOk      = "false";
                result.ReturnMessage = "";
            }
            return(result);
        }