public ActionResult deleteHotelRoom(int RoomID) { //string json = new System.IO.StreamReader(Request.InputStream).ReadToEnd(); //JObject jObject = JObject.Parse(json); //int RoomID = Convert.ToInt32(jObject["RoomID"] ?? 0); string msg = ""; using (HotelDBEntities db = new HotelDBEntities()) { HotelMaster room = db.HotelMasters.Where(a => a.RoomID == RoomID).FirstOrDefault(); if (room != null) { room.Flag = "D"; msg = "刪除完成!!"; db.SaveChanges(); } else { msg = "Error - 查無此ID!!"; } } //return Content(msg, "application/json"); //return new JsonResult { Data = new string[] { msg }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return(Json(new string[] { msg }, JsonRequestBehavior.AllowGet)); }
public void TestSquareConstruct() { HotelMaster hotelMaster = new HotelMaster(); Assert.IsNotNull(hotelMaster.RankChiefs[0].Squares[0].Tables); Assert.IsNotNull(hotelMaster.RankChiefs[0].Squares[0].Waiters); Assert.AreEqual(Parameters.TABLES_BY_SQUARE, hotelMaster.RankChiefs[0].Squares[0].Tables.Count); Assert.AreEqual(Parameters.WAITER_BY_SQUARE, hotelMaster.RankChiefs[0].Squares[0].Waiters.Count); }
public IEnumerable <string> modifyHotelRoom(JObject jObject) { int RoomID = Convert.ToInt32(jObject["RoomID"] ?? 0); string RoomNo = (jObject["RoomNo"] ?? "").ToString(); string RoomType = (jObject["RoomType"] ?? "").ToString(); string Prize = (jObject["Prize"] ?? "").ToString(); string msg = ""; var r = db.HotelMasters.Where(a => a.RoomNo == RoomNo && a.RoomID != RoomID).FirstOrDefault(); if (r != null) { msg = "Error - 已有此房號!!"; } else { if (RoomID == 0) { //Insert var Room = new HotelMaster(); Room.RoomNo = RoomNo; Room.RoomType = RoomType; Room.Prize = Prize; Room.Flag = "A"; db.HotelMasters.Add(Room); msg = "新增完成!!"; } else { //Update var v = db.HotelMasters.Where(a => a.RoomID == RoomID).FirstOrDefault(); if (v != null) { v.RoomNo = RoomNo; v.RoomType = RoomType; v.Prize = Prize; v.Flag = "U"; msg = "更新完成!!"; } else { msg = "Error - 查無此ID!!"; } } db.SaveChanges(); } return(new string[] { msg }); }
public ActionResult modifyHotelRoom(int RoomID, string RoomNo, string RoomType, string Prize) { string msg = ""; using (HotelDBEntities db = new HotelDBEntities()) { var r = db.HotelMasters.Where(a => a.RoomNo == RoomNo && a.RoomID != RoomID).FirstOrDefault(); if (r != null) { msg = "Error - 已有此房號!!"; } else { if (RoomID == 0) { //Insert var Room = new HotelMaster(); Room.RoomNo = RoomNo; Room.RoomType = RoomType; Room.Prize = Prize.ToBig5(); Room.Flag = "A"; db.HotelMasters.Add(Room); msg = "新增完成!!"; } else { //Update var v = db.HotelMasters.Where(a => a.RoomID == RoomID).FirstOrDefault(); if (v != null) { v.RoomNo = RoomNo; v.RoomType = RoomType; v.Prize = Prize.ToBig5(); v.Flag = "U"; msg = "更新完成!!"; } else { msg = "Error - 查無此ID!!"; } } db.SaveChanges(); } } return(Json(new string[] { msg }, JsonRequestBehavior.AllowGet)); }
public void TestAttributionTableGroup() { HotelMaster hotelMaster = new HotelMaster(); WelcomeController welcomeController = new WelcomeController(hotelMaster); Group group = welcomeController.CreateGroup(5); TableController tableController = new TableController(); Table table = tableController.OptimizedFindTable(hotelMaster.RankChiefs[0].Squares[0].Tables, group.Clients.Count); if (table == null) { table = tableController.OptimizedFindTable(hotelMaster.RankChiefs[1].Squares[0].Tables, group.Clients.Count); } Assert.IsNotNull(table); bool success = tableController.AttributionTableGroup(group, table); Assert.IsTrue(success); Assert.AreEqual(EquipmentState.InUse, table.State); Assert.AreEqual(GroupState.Ordering, group.State); }
public void TestHotelMasterConstruct() { HotelMaster BasicHotelMaster = new HotelMaster(); Assert.AreEqual(0, BasicHotelMaster.PosX); Assert.AreEqual(0, BasicHotelMaster.PosY); Assert.AreEqual(Parameters.RANKCHIEF_NUMBER, BasicHotelMaster.RankChiefs.Count); HotelMaster PositionedHotelMaster = new HotelMaster(1, 11); Assert.AreEqual(1, PositionedHotelMaster.PosX); Assert.AreEqual(11, PositionedHotelMaster.PosY); Assert.AreEqual(Parameters.RANKCHIEF_NUMBER, PositionedHotelMaster.RankChiefs.Count); HotelMaster WrongPositioningHotelMaster = new HotelMaster(-6, -8); Assert.AreEqual(0, WrongPositioningHotelMaster.PosX); Assert.AreEqual(0, WrongPositioningHotelMaster.PosY); Assert.IsNotNull(BasicHotelMaster.RankChiefs); Assert.IsNotNull(PositionedHotelMaster.RankChiefs); Assert.AreEqual(Parameters.RANKCHIEF_NUMBER, WrongPositioningHotelMaster.RankChiefs.Count); }
public void SetUp() { hotelMaster = new HotelMaster(30, 40); welcomeController = new WelcomeController(hotelMaster); }
public SalleModel() { hotelMaster = new HotelMaster(); }
public WelcomeController(HotelMaster hotelMaster) { this.hotelMaster = hotelMaster; }