Example #1
0
        public CargoFavoriteListModel GetCargoFavoriteList(uint userID)
        {
            List <ViewCargoFaoriteListModel> list;

            String where = String.Format("view_cargofavoritelist.aid={0}", userID);

            try
            {
                list = db.SelectData <ViewCargoFaoriteListModel>("view_cargofavoritelist", where);
            }catch (Database.Exception ex)
            {
                switch (ex.Code)
                {
                case 1062:
                    throw new UnfulfilException("/language/database/duplicate_entry");

                default: throw (ex);
                }
            }

            CargoFavoriteListModel favoriteList = new CargoFavoriteListModel();

            foreach (ViewCargoFaoriteListModel favorite in list)
            {
                favoriteList.Add(favorite);
            }

            return(favoriteList);
        }
Example #2
0
        protected override void OnRequest()
        {
            base.OnRequest();

            CargoFavoriteListModel favoriteList = null;

            try
            {
                favoriteList = new Controller.Favorite().GetCargoFavoriteList(aid);
                WriteSuccess <CargoFavoriteListModel>(favoriteList);
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (Database.Exception ex)
            {
                WriteException(ex);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }