Exemplo n.º 1
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add update logic here
                    Restaurant temp = new Restaurant
                    {
                        Id                    = id,
                        RestaurantName        = collection["restaurantName"],
                        RestaurantAddress     = collection["restaurantAddress"],
                        RestaurantCity        = collection["restaurantCity"],
                        RestaurantState       = collection["restaurantState"],
                        RestaurantPhoneNumber = collection["restaurantPhoneNumber"],
                        RestaurantURL         = collection["restaurantURL"]
                    };
                    LibHelper.EditRestaurant(temp);

                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    return(View());
                }
            }
            else
            {
                return(View("Invalid Model State"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(FormCollection collection) //***TODO*** Need to finish the catch for this methdo
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Restaurant temp = new Restaurant
                    {
                        RestaurantName        = collection["restaurantName"],
                        RestaurantAddress     = collection["restaurantAddress"],
                        RestaurantCity        = collection["restaurantCity"],
                        RestaurantState       = collection["restaurantState"],
                        RestaurantPhoneNumber = collection["restaurantPhoneNumber"],
                        RestaurantURL         = collection["restaurantURL"]
                    };
                    LibHelper.AddRestaurant(temp);

                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    return(View());
                }
            }
            else
            {
                return(View("Invalid Model State"));
            }
        }
Exemplo n.º 3
0
        // GET: Restaurant
        public ActionResult Index(string SearchString, string sort)
        {
            List <Restaurant> allRestaurants = (List <Restaurant>)LibHelper.ShowAllRestaurants();

            ViewBag.SearchString = SearchString;
            if (!String.IsNullOrEmpty(SearchString))
            {
                return(View(sorter.SearchRestaurantByName(SearchString, allRestaurants)));
            }
            ViewBag.Top3         = sort == "Top3Rating" ? "sortTop3" : "Top3Rating";
            ViewBag.SortByRating = sort == "RatingsDescending" ? "ByRatings" : "RatingsDescending";
            ViewBag.SortByName   = sort == "NamesAscending" ? "ByNames" : "NamesAscending";

            if (sort == "Top3Rating")
            {
                return(View(sorter.SortByRating(3, allRestaurants)));
            }
            if (sort == "RatingsDescending")
            {
                return(View(sorter.SortByRating(allRestaurants)));
            }
            if (sort == "NamesAscending")
            {
                return(View(sorter.SortByNameAscending(allRestaurants)));
            }
            else
            {
                return(View(LibHelper.ShowAllRestaurants()));
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit(int id, int id2, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add update logic here
                    Review temp = new Review
                    {
                        Id           = id2,
                        RestaurantID = id,
                        ReviewerName = collection["reviewerName"],
                        ReviewText   = collection["reviewText"],
                        ReviewScore  = (float)Convert.ToDouble(collection["reviewScore"])
                    };

                    LibHelper.EditReview(temp);
                    return(RedirectToAction("ListReviews/" + id));
                }
                catch (Exception e)
                {
                    return(View());
                }
            }
            else
            {
                return(View("Model State is Invalid"));
            }
        }
Exemplo n.º 5
0
        public ActionResult Create(FormCollection collection, int id)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Review temp = new Review
                    {
                        RestaurantID = id,
                        ReviewerName = collection["reviewerName"],
                        ReviewScore  = (float)Convert.ToDouble(collection["reviewScore"]),
                        ReviewText   = collection["reviewText"]
                    };

                    LibHelper.AddReview(temp);

                    return(RedirectToAction("ListReviews/" + id));
                }
                catch (Exception e)
                {
                    return(View());
                }
            }
            else
            {
                return(View("Model State is invalid."));
            }
        }
Exemplo n.º 6
0
        private void UpdateConfigInfo()
        {
            string ip           = txtIp.Text;
            string port         = txtPort.Text;
            string useName      = txtUserName.Text;
            string password     = txtPassowrd.Text;
            string dataBaseName = txtDataBaseName.Text;

            LibHelper.UpdateConfig(ip, port, useName, password, dataBaseName);
        }
Exemplo n.º 7
0
 public ActionResult DeleteRestaurant(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         LibHelper.DeleteFromDatabase(id);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         return(View());
     }
 }
Exemplo n.º 8
0
 public ActionResult Delete(int id, int id2, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         LibHelper.DeleteReviewFromDatabase(id2);
         return(RedirectToAction("ListReviews/" + id));
     }
     catch
     {
         return(View());
     }
 }
        public void TestLibHelper()
        {
            //arrange
            LibHelper libHelper = new LibHelper();
            String    restName  = "IHOP";
            String    expected  = "Diner";
            String    actual    = "";

            //act
            var results = libHelper.GetRestaurants();

            //assert
            foreach (var restaurant in results)
            {
                if (restaurant.Name == restName)
                {
                    actual = restaurant.FoodType;
                }
            }
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter new Restaurant name: ");
            var newName = Console.ReadLine();

            var libHelper = new LibHelper();

            libHelper.AddRestaurant(new Restaurant()
            {
                Name = newName
            });
            // saves changes, updates dbsets

            var results = libHelper.GetRestaurants();

            Console.WriteLine("All stored restaurants:");
            foreach (var restaurant in results)
            {
                Console.WriteLine(restaurant.Name);
            }

            Console.ReadKey();
        }
Exemplo n.º 11
0
 // GET: Restaurant/Edit/5
 public ActionResult Edit(int id)
 {
     return(View(LibHelper.GetRestaurantById(id)));
 }
Exemplo n.º 12
0
        /// <summary>
        /// 后台数据库插入
        /// </summary>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        private int CreateDataByMc(DateTime startTime, DateTime endTime, int startCode, int endCode, int OneNum, int OneSleep)
        {
            try
            {
                SetProgess("0%");
                SetMsg("正在检查数据库连接");
                bool result = Common.CheckDataBaseExist();

                if (!result)
                {
                    return(1);
                }

                SetProgess("2%");
                SetMsg("正在获取指定用户信息");
                mc_user userInfo = LibHelper.GetUserInfoByPoliceCodeMC(GetTextBoxValue(txtPoliceCode));

                if (userInfo == null)
                {
                    return(2);
                }

                SetProgess("5%");
                SetMsg("正在获取组织架构信息");
                List <mc_organization> orgList = LibHelper.GetOrgInfosMC();
                if (orgList == null || orgList.Count == 0)
                {
                    return(3);
                }

                SetProgess("8%");
                SetMsg("正在获取设备信息");
                List <mc_device> deviceInfos = LibHelper.GetDeviceInfosMC(GetTextBoxValue(txtDeviceID));
                if (deviceInfos == null || deviceInfos.Count == 0)
                {
                    return(4);
                }

                mc_organization userOrgInfo = orgList.Find(p => p.org_id.Equals(userInfo.org_id));
                if (userOrgInfo == null)
                {
                    return(5);
                }

                int count = 0;
                int index = 0;
                for (int i = startCode; i <= endCode; i++)
                {
                    if (GetCheckValue(cbDeviceLog))
                    {
                        index++;
                        SetMsg(string.Format("正在为{0}创建WEB执法记录仪操作日志信息", i));
                        count += LibHelper.AddCameraLogByMc(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            i.ToString(),
                            GetTextBoxValue(txtDeviceCode),
                            userInfo,
                            orgList,
                            userOrgInfo,
                            deviceInfos,
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }

                    if (GetCheckValue(cbStationLog))
                    {
                        index++;
                        SetMsg(string.Format("正在为{0}创建WEB采集站操作日志信息", i));
                        count += LibHelper.AddStationLogByMC(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            startCode.ToString(),
                            GetTextBoxValue(txtClientCode),
                            userInfo,
                            userOrgInfo,
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }

                    if (GetCheckValue(cbMediaLog))
                    {
                        index++;
                        SetMsg(string.Format("正在为{0}创建WEB媒体数据信息", i));
                        count += LibHelper.AddMediaLogMC(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            i.ToString(),
                            userInfo,
                            userOrgInfo,
                            deviceInfos,
                            orgList,
                            GetTextBoxValue(txtVideo),
                            GetTextBoxValue(txtAudio),
                            GetTextBoxValue(txtImage),
                            GetTextBoxValue(txtCollectDir),
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }
                    //if (GetCheckValue(cbalarmLog))
                    //{
                    //    index++;
                    //    SetMsg("正在创建WEB告警信息");
                    //    count += LibHelper.AddAlarmlog(
                    //                                       startTime,
                    //                                       endTime,
                    //                                       Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                    //                                       GetTextBoxValue(txtAlarmCode),
                    //                                       index,
                    //                                       CountProgess
                    //                                       );
                    //}

                    if (GetCheckValue(cbManageLog))
                    {
                        index++;
                        SetMsg(string.Format("正在为{0}创建媒体数据信息", i));
                        count += LibHelper.AddManageCenterlog(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            i.ToString(),
                            userInfo,
                            userOrgInfo,
                            GetTextBoxValue(txtManageCode),
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }

                    //if (GetCheckValue(cbStatusLog))
                    //{
                    //    index++;
                    //    SetMsg("正在创建WEB状态信息");
                    //    count += LibHelper.AddStatuslog(
                    //                                       startTime,
                    //                                       endTime,
                    //                                       Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                    //                                       index,
                    //                                       CountProgess
                    //                                       );
                    //}
                }

                SetProgess("100%");
                SetMsg("创建WEB模拟信息完成");
                return(count);
            }
            catch (Exception e)
            {
                error = e.Message;
                return(-1);
            }
        }
Exemplo n.º 13
0
 // GET: Review/Edit/5
 public ActionResult Edit(int id, int id2)
 {
     ViewBag.id = id;
     return(View(LibHelper.GetReviewFromRestaurant(id, id2)));
 }
Exemplo n.º 14
0
 // GET: Review/ListReviews/5
 public ActionResult ListReviews(int id)
 {
     ViewBag.id = id;
     return(View(LibHelper.ShowAllReviews(id)));
 }