예제 #1
0
        public async Task UpdateLuggageStatus(string luggageId, LuggageStatus luggageStatus)
        {
            try
            {
                Luggage luggage = await DAL.GetLuggage(luggageId);

                // LuggageStatusEnum status = (LuggageStatusEnum) Enum.Parse(typeof(LuggageStatusEnum), luggageStatus, true);

                if (luggage == null)
                {
                    throw new ArgumentException("No such luggage to update");
                }
                else
                {
                    luggage.Status           = luggageStatus;
                    luggage.LastStatusChange = DateTime.Now;
                    await DAL.UpdateLuggage(luggage);
                }
            }
            catch (ArgumentException ex)
            {
                throw new LuggageTrackerBizContextException("Invalid Argument", ex)
                      {
                          StatusCode = HttpStatusCode.BadRequest,
                      };
            }
            catch (Exception ex)
            {
                throw new LuggageTrackerBizContextException("Failed to update luggage status", ex)
                      {
                          StatusCode = HttpStatusCode.InternalServerError,
                      };
            }
        }
예제 #2
0
        public async Task <IHttpActionResult> PostLuggage(Luggage luggage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Luggages.Add(luggage);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (LuggageExists(luggage.Luggage_RFID_Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = luggage.Luggage_RFID_Id }, luggage));
        }
예제 #3
0
        public async Task ShouldUpdateLuggageStatusSuccessfully()
        {
            string luggageStringStatus = "Registered";

            //TODO   Detailed Lugage status Test
            luggage.LuggageId = luggageId;
            HttpResponseMessage createResult = await luggageController.AddLuggage(luggage);

            Assert.AreEqual(createResult.StatusCode, HttpStatusCode.Created, "Verify luggage created");

            //luggage.Status = luggageStatus;
            luggageStatus.Status = LuggageStatusEnum.Registered;

            luggageController.ControllerContext = new ControllerContext();
            HttpResponseMessage updatedResult = await luggageController.UpdateLuggageStatus(luggageId, luggageStatus);

            Assert.AreEqual(updatedResult.StatusCode, HttpStatusCode.OK, "Verify luggage modified");

            HttpResponseMessage getResult = await luggageController.GetLuggage(luggageId);

            Assert.AreEqual(getResult.StatusCode, HttpStatusCode.OK, "verify luggage get");

            string json = await getResult.Content.ReadAsStringAsync();

            Luggage newLuggage = JsonConvert.DeserializeObject <Luggage>(json);

            Assert.AreEqual(newLuggage.Status.Status, LuggageStatusEnum.Registered);
        }
예제 #4
0
 void Start()
 {
     StartPoint = transform.localPosition;
     nameInfo   = panelInfo.GetComponentInChildren <Text>();
     hasExit    = false;
     luggage    = transform.parent.GetComponent <Luggage>();
 }
        public EditLuggage(LuggageManager manager, Luggage l)
        {
            InitializeComponent();
            luggageManager = manager;
            luggage        = l;
            List <LuggageStatus> status      = luggageManager.RetrieveAllLuggageStatus();
            List <string>        statusNames = new List <string>();

            foreach (var name in status)
            {
                statusNames.Add(name.LuggageStatusID);
            }
            cboStatus.ItemsSource = statusNames;
            if (l.Status.Equals("In Lobby"))
            {
                cboStatus.SelectedIndex = 0;
            }
            else if (l.Status.Equals("In Room"))
            {
                cboStatus.SelectedIndex = 1;
            }
            else
            {
                cboStatus.SelectedIndex = 2;
            }
        }
예제 #6
0
        public async Task <ActionResult <Luggage> > PostLuggage(Luggage luggage)
        {
            _context.Luggages.Add(luggage);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLuggage", new { id = luggage.LUGGAGEID }, luggage));
        }
예제 #7
0
        public void ParseLuggageSection(string input, string id, int quantity)
        {
            Luggage result = Logic.ParseLuggage(input);

            Assert.Equal(quantity, result.Quantity);
            Assert.Equal(id, result.Id);
        }
        public bool CreateLuggage(Luggage l)
        {
            bool   result  = false;
            var    conn    = DBConnection.GetDbConnection();
            string cmdText = @"sp_insert_luggage";
            var    cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@GuestID", SqlDbType.Int);
            cmd.Parameters.Add("@LuggageStatusID", SqlDbType.NVarChar, 50);
            cmd.Parameters["@GuestID"].Value         = l.GuestID;
            cmd.Parameters["@LuggageStatusID"].Value = l.Status;
            try
            {
                conn.Open();
                result = cmd.ExecuteNonQuery() == 1;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(result);
        }
예제 #9
0
        public async Task <IHttpActionResult> PutLuggage(string id, Luggage luggage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != luggage.Luggage_RFID_Id)
            {
                return(BadRequest());
            }

            db.Entry(luggage).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LuggageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #10
0
        public async Task <Luggage> GetLuggage(string tagId)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(tagId))
                {
                    throw new ArgumentNullException("Tag Id", "Invalid TagId");
                }

                Luggage luggage = await DAL.GetLuggage(tagId);

                if (luggage is null)
                {
                    throw new NullReferenceException("null object was returned for this parameter");
                }

                return(luggage);
            }
            catch (NullReferenceException ex)
            {
                throw new LuggageTrackerBizContextException("Failed to get luggage with TagId", ex)
                      {
                          StatusCode = HttpStatusCode.NotFound,
                      };
            }
            catch (Exception ex)
            {
                throw new LuggageTrackerBizContextException("Failed to get luggage with TagId", ex)
                      {
                          StatusCode = HttpStatusCode.InternalServerError,
                      };
            }
        }
예제 #11
0
        public async Task <IActionResult> PutLuggage(int id, Luggage luggage)
        {
            if (id != luggage.LUGGAGEID)
            {
                return(BadRequest());
            }

            _context.Entry(luggage).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LuggageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #12
0
 protected void OnTriggerExit2D(Collider2D c)
 {
     if (c.CompareTag("Luggage") && !onPickupLuggage)
     {
         m_luggage = null;
     }
 }
예제 #13
0
 public async Task UpdateLuggage(Luggage luggage)
 {
     try
     {
         Validator.ValidateLuggageOrThrowException(luggage);
         if (DAL.GetLuggage(luggage.LuggageId) == null)
         {
             throw new ArgumentException("No such luggage to update");
         }
         await DAL.UpdateLuggage(luggage);
     }
     catch (ArgumentException ex)
     {
         throw new LuggageTrackerBizContextException("Invalid Argument", ex)
               {
                   StatusCode = HttpStatusCode.BadRequest,
               };
     }
     catch (Exception ex)
     {
         throw new LuggageTrackerBizContextException("Failed to update luggage", ex)
               {
                   StatusCode = HttpStatusCode.InternalServerError,
               };
     }
 }
예제 #14
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Luggage = await _context.Luggages
                      .Include(l => l.FLIGHT).FirstOrDefaultAsync(m => m.LUGGAGEID == id);

            if (Luggage == null)
            {
                return(NotFound());
            }

            var flights = _context.Flights
                          .Select(f => new
            {
                f.FLIGHTID,
                Description = $"{f.CIE} {f.LIG} : {f.DHC.ToShortDateString()}"
            }).ToList();

            ViewData["FLIGHTID"] = LuggagesHelper.ListFlightInfo(_context); //on utilise LuggageHelper pour avoir les infos sur les vols

            return(Page());
        }
예제 #15
0
 public ActionResult Edit([Bind(Include = "Id,MaximumWeight,Price")] Luggage luggage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(luggage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(luggage));
 }
예제 #16
0
        public async Task <IHttpActionResult> GetLuggage(string id)
        {
            Luggage luggage = await db.Luggages.FindAsync(id);

            if (luggage == null)
            {
                return(NotFound());
            }

            return(Ok(luggage));
        }
        private void InitLuggage()
        {
            Luggage luggage1 = new Luggage();

            luggage1.Weight = 50;
            Luggage luggage2 = new Luggage();

            luggage2.Weight = 60;
            Luggages.Add(luggage1);
            Luggages.Add(luggage2);
        }
        private void openView(Luggage l)
        {
            var frmView = new EditLuggage(luggageManager, l);

            if (frmView.ShowDialog() == true)
            {
                MessageBox.Show("Luggage Updated.");
                setupWindow();
            }
            return;
        }
예제 #19
0
        public ActionResult Create([Bind(Include = "Id,MaximumWeight,Price")] Luggage luggage)
        {
            if (ModelState.IsValid)
            {
                db.Luggages.Add(luggage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(luggage));
        }
예제 #20
0
        public ActionResult DeleteConfirmed(int id)
        {
            Luggage luggage = db.Luggages.Find(id);

            if (luggage != null)
            {
                db.Luggages.Remove((Luggage)luggage);
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
        public Luggage RetrieveLuggageByID(int id)
        {
            Luggage l = null;

            l = _luggage.Find(x => x.LuggageID == id);
            if (l == null)
            {
                throw new ApplicationException("Couldn't find any Luggage with matching ID.");
            }
            return(l);
        }
예제 #22
0
        public async Task ShouldUpdateLuggageSuccessfully()
        {
            string tag = Guid.NewGuid().ToString();

            luggage.LuggageId = tag;
            await DALContext.AddLuggage(luggage);

            Luggage newLuggage = await DALContext.GetLuggage(tag);

            Assert.AreEqual(tag, newLuggage.LuggageId);

            string   description      = "TestLuggage";
            string   weight           = "1 KG";
            string   name             = "TestName";
            string   measurement      = "1 Meters";
            DateTime lastStatusChange = DateTime.Now;

            UInt64 statusId          = 123456;
            string statusDescription = "Test Status Description Updated";
            string latitude          = "1";
            string longitude         = "1";


            newLuggage.Description      = description;
            newLuggage.Weight           = weight;
            newLuggage.Name             = name;
            newLuggage.Measurement      = measurement;
            newLuggage.LastStatusChange = lastStatusChange;

            newLuggage.Status.LuggageStatusId    = statusId;
            newLuggage.Status.Status             = LuggageStatusEnum.CheckedIn;
            newLuggage.Status.StatusDescription  = statusDescription;
            newLuggage.Status.Location.Latitude  = latitude;
            newLuggage.Status.Location.Longitude = longitude;


            await DALContext.UpdateLuggage(newLuggage);

            Luggage updatedLuggage = await DALContext.GetLuggage(tag);

            Assert.AreEqual(tag, updatedLuggage.LuggageId);
            Assert.AreEqual(description, updatedLuggage.Description);
            Assert.AreEqual(weight, updatedLuggage.Weight);
            Assert.AreEqual(name, updatedLuggage.Name);
            Assert.AreEqual(measurement, updatedLuggage.Measurement);
            Assert.AreEqual(lastStatusChange, updatedLuggage.LastStatusChange);

            Assert.AreEqual(statusId, newLuggage.Status.LuggageStatusId);
            Assert.AreEqual(LuggageStatusEnum.CheckedIn, (object)newLuggage.Status.Status);
            Assert.AreEqual(statusDescription, newLuggage.Status.StatusDescription);
            Assert.AreEqual(latitude, newLuggage.Status.Location.Latitude);
            Assert.AreEqual(longitude, newLuggage.Status.Location.Longitude);
        }
예제 #23
0
    protected void OnTriggerEnter2D(Collider2D c)
    {
        if (c.CompareTag("Luggage"))
        {
            m_luggage = c.GetComponent <Luggage>();
        }

        if (c.CompareTag("Heart"))
        {
            Destroy(c.gameObject);
            GameMng.Instance.GetHeart();
        }
    }
예제 #24
0
        public async Task AddLuggage(Luggage luggage)
        {
            try
            {
                Validator.ValidateLuggageOrThrowException(luggage, true);

                await Task.Run(() => Luggages.Add(luggage));
            }
            catch
            {
                throw;
            }
        }
 /// <summary>
 /// Used to update luggage control
 /// </summary>
 public void Update(Luggage luggage)
 {
     if (luggage != null)
     {
         Rect_Counter.Fill  = AirportColors.GetColorById(luggage.CounterId);
         Rect_Terminal.Fill = AirportColors.GetColorById(luggage.TerminalId);
     }
     else
     {
         Rect_Counter.Fill  = Brushes.Black;
         Rect_Terminal.Fill = Brushes.Black;
     }
 }
예제 #26
0
        public IActionResult AddNewLuggage(Luggage luggage)
        {
            var luggagesCount = _luggageService.GetLuggagesCount();

            if (luggagesCount + luggage.NumberOfLuggages <= _maxLuggages)
            {
                luggage.CreatedAt  = DateTime.Now;
                luggage.AccessCode = Regex.Replace(Convert.ToBase64String(Guid.NewGuid().ToByteArray()), "[/+=]", "");
                return(Ok(_luggageService.AddNewLuggage(luggage)));
            }

            return(Conflict("Luggage limit exceeded !"));
        }
예제 #27
0
        // GET: Luggages/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Luggage luggage = db.Luggages.Find(id);

            if (luggage == null)
            {
                return(HttpNotFound());
            }
            return(View(luggage));
        }
예제 #28
0
        public async Task <IActionResult> Create(CreateLuggageViewModel inputModel)
        {
            var currentUser = await this._userManager.GetUserAsync(HttpContext.User);

            var luggage = new Luggage
            {
                Weights           = inputModel.Weight,
                ApplicationUserId = currentUser.Id
            };

            await this.luggages.Save(luggage);

            return(Ok());
        }
예제 #29
0
        public async Task <IHttpActionResult> DeleteLuggage(string id)
        {
            Luggage luggage = await db.Luggages.FindAsync(id);

            if (luggage == null)
            {
                return(NotFound());
            }

            db.Luggages.Remove(luggage);
            await db.SaveChangesAsync();

            return(Ok(luggage));
        }
        public ActionResult ReturnToShowLuggages()
        {
            string cur_state = Request.Params["s"];

            cur_state = cur_state.Trim();

            if (cur_state == "已登机")
            {
                MessageBox.Show("该行李已经登机啦!");
            }
            else
            {
                int    Luggage_ID = int.Parse(Request.Params["l_id"]);
                string Flight_ID  = Request.Params["ff_id"];
                Flight_ID = Flight_ID.Trim();
                int           w = int.Parse(Request.Params["w"]);
                StringBuilder s = new StringBuilder();
                s.Append("已登机");

                LUGGAGE objlug = new LUGGAGE()
                {
                    F_ID = Flight_ID, L_ID = Luggage_ID, WEGHT = Convert.ToInt16(w), STATE = s.ToString()
                };
                db.Updateable(objlug).ExecuteCommand();
            }
            List <Luggage> Luggages = new List <Luggage>();
            List <object>  list     = new List <object>(); //对象
            List <string>  value    = new List <string>(); //值
            Luggage        obj      = new Luggage();
            SelectReturn   sr       = DataBaseAccess.GetAllTInfo(obj);

            list  = sr.list;
            value = sr.value;
            //obj转Luggage
            int flag = 0;

            foreach (object j in list)
            {
                Luggage luggage = new Luggage();//current
                //手动赋值,暂时没有找到映射的方法
                luggage.F_ID  = value[flag++];
                luggage.L_ID  = int.Parse(value[flag++]);
                luggage.Weght = int.Parse(value[flag++]);
                luggage.State = value[flag++];
                Luggages.Add(luggage);
            }
            //
            return(View("ShowLuggages", Luggages));
        }
예제 #31
0
        public void LoadContent(Game1 g)
        {
            spriteFont = g.Content.Load<SpriteFont>("SpriteFont");
            LoadTextures(g);

            sariandi = new FemaleCharacter(g.Content, "GoodCharacter\\femaleRight", "GoodCharacter\\femaleLeft",
            "GoodCharacter\\femaleUp", "GoodCharacter\\femaleDown", 200f, 4, true);
            aias = new MaleCharacter(g.Content, "GoodCharacter\\maleRight", "GoodCharacter\\maleLeft",
                "GoodCharacter\\maleUp", "GoodCharacter\\maleDown", 200f, 4, true);

            health = new Health(g.Content, "Items\\Health", DefaultHealth);

            death = new Death(g.Content, "EvilCharacter\\deathRight", "EvilCharacter\\deathLeft",
                "EvilCharacter\\deathUp", "EvilCharacter\\deathDown", 200f, 4, true);
            luggage = new Luggage(g.Content, "EvilCharacter\\luggageRight", "EvilCharacter\\luggageLeft",
                "EvilCharacter\\luggageUp", "EvilCharacter\\luggageDown", 200f, 4, true);
            dragon = new Dragon(g.Content, "EvilCharacter\\dragonRight", "EvilCharacter\\dragonLeft",
                "EvilCharacter\\dragonUp", "EvilCharacter\\dragonDown", 200f, 4, true);
            emptyCollisionBox = new EmptyCollisionBox();

            goodCharacters.Add(aias);
            goodCharacters.Add(sariandi);

            shield = new Shield(g.Content, "Items\\Shield", DefaultShield);

            evilCharacters.Add(death);
            evilCharacters.Add(luggage);
            evilCharacters.Add(dragon);

            healthBar = new HealthBar(g.Content, "Bars\\bloodbar");
            shieldBar = new ShieldBar(g.Content, "Bars\\shieldbar");
            expirienceBar = new ExpirienceBar(g.Content, "Bars\\expiriencebar");

            expirience = new Expirience(g.Content, "Items\\Axe", DefaultExpirience);

            items.Add(health);
            items.Add(shield);
            items.Add(expirience);
            map.loadContent(g.GraphicsDevice);
        }