Beispiel #1
0
        /// <summary>
        /// Convert item to item model
        /// </summary>
        /// <param name="item">Item</param>
        /// <returns>Item model</returns>
        public ItemModel ToItemModel(Item item)
        {
            // Local variable declaration
            ItemModel      itemModel      = null;
            StorageFileCom storageFileCom = null;

            // Variable initialize
            itemModel      = new ItemModel();
            storageFileCom = new StorageFileCom();

            // Copy infomation
            DataHelper.CopyObject(item, itemModel);

            // Get value
            var storageFile  = storageFileCom.GetSingle(item.FileId, true);
            var itemImage    = storageFile != null ? storageFile.FileName : "default.jpg";
            var storageFiles = storageFileCom.GetListActive(item.FileId, true);

            if (DataCheckHelper.IsNull(storageFiles))
            {
                storageFiles.Add(new StorageFile()
                {
                    FileName = "default.jpg"
                });
            }

            // Set value
            itemModel.ItemImage      = itemImage;
            itemModel.ItemImages     = storageFiles;
            itemModel.ListOfferItems = new List <OfferItem>();

            // Check offer
            if (_comDao.HasOffer(itemModel.ItemCd))
            {
                var offer = _comDao.GetOffer(itemModel.ItemCd);

                itemModel.OfferDiv = offer.OfferDiv;
                itemModel.ItemDiv  = Logics.TEXT_BLANK;

                if (itemModel.OfferDiv == Logics.CD_OFFER_DIV_DISCOUNT)
                {
                    itemModel.SalesPriceOld = itemModel.SalesPrice;
                    itemModel.SalesPrice    = GetOfferPrice(itemModel.SalesPrice, offer.Percent);
                }
                else
                {
                    itemModel.ListOfferItems = offer.OfferItems;
                }
            }

            // Return value
            return(itemModel);
        }
Beispiel #2
0
        /// <summary>
        /// Convert item to item model
        /// </summary>
        /// <param name="item">Item</param>
        /// <returns>Item model</returns>
        public ItemModel ToItemModel(Item item)
        {
            // Local variable declaration
            ItemModel itemModel = null;
            StorageFileCom storageFileCom = null;

            // Variable initialize
            itemModel = new ItemModel();
            storageFileCom = new StorageFileCom();

            // Copy infomation
            DataHelper.CopyObject(item, itemModel);

            // Get value
            var storageFile = storageFileCom.GetSingle(item.FileId, true);
            var itemImage = storageFile != null ? storageFile.FileName : "default.jpg";
            var storageFiles = storageFileCom.GetListActive(item.FileId, true);
            if (DataCheckHelper.IsNull(storageFiles)) storageFiles.Add(new StorageFile() { FileName = "default.jpg" });

            // Set value
            itemModel.ItemImage = itemImage;
            itemModel.ItemImages = storageFiles;
            itemModel.ListOfferItems = new List<OfferItem>();

            // Check offer
            if (_comDao.HasOffer(itemModel.ItemCd))
            {
                var offer = _comDao.GetOffer(itemModel.ItemCd);

                itemModel.OfferDiv = offer.OfferDiv;
                itemModel.ItemDiv = Logics.TEXT_BLANK;

                if (itemModel.OfferDiv == Logics.CD_OFFER_DIV_DISCOUNT)
                {
                    itemModel.SalesPriceOld = itemModel.SalesPrice;
                    itemModel.SalesPrice = GetOfferPrice(itemModel.SalesPrice, offer.Percent);
                }
                else
                {
                    itemModel.ListOfferItems = offer.OfferItems;
                }
            }

            // Return value
            return itemModel;
        }
Beispiel #3
0
        /// <summary>
        /// Check processing
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>ResultModel</returns>
        private void Check(DeleteDataModel inputObject)
        {
            // Local variable declaration
            StorageFileCom storageFileCom = null;

            // Variable initialize
            storageFileCom = new StorageFileCom();

            // Check valid
            int i = 0;
            foreach (var obj in inputObject.ListFiles)
            {
                if (DataCheckHelper.IsNull(obj.FileId))
                    throw new ExecuteException("E_MSG_00004", string.Format("Mã tập tin ({0})", i + 1));
                if (DataCheckHelper.IsNull(obj.FileNo))
                    throw new ExecuteException("E_MSG_00004", string.Format("Số tập tin ({0})", i + 1));
                if (!storageFileCom.IsExist(obj.FileId, obj.FileNo, true))
                    throw new DataNotExistException(string.Format("Tập tin ({0})", i + 1));
                i++;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Save infomation
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private SaveDataModel SaveInfo(SaveDataModel inputObject)
        {
            // Local variable declaration
            SaveDataModel saveResult = null;
            AdminBrandEntryDao adminBrandEntryDao = null;
            StorageFileCom storageFileCom = null;

            // Variable initialize
            saveResult = new SaveDataModel();
            adminBrandEntryDao = new AdminBrandEntryDao();
            storageFileCom = new StorageFileCom();

            if (IsAdd) adminBrandEntryDao.InsertBrand(inputObject); // Insert
            else adminBrandEntryDao.UpdateBrand(inputObject); // Update

            // Update StorageFile
            foreach (var storageFile in storageFileCom.GetListActive(inputObject.FileId, false))
            {
                storageFile.ActiveFlag = true;
                storageFileCom.UpdateActiveFlag(storageFile, false);
            }
            storageFileCom.SubmitChanges();

            return saveResult;
        }
Beispiel #5
0
        /// <summary>
        /// Execute convert ouput.
        /// </summary>
        /// <param name="resultObject">DataModel</param>
        /// <returns>ResponseModel</returns>
        private InitResponseModel Convert(InitDataModel resultObject)
        {
            // Local variable declaration
            InitResponseModel responseModel = null;
            OutputDetailsModel details = null;
            IList<OutputImageModel> listImages = null;
            IList<OutputItemModel> listOfferItems = null;
            IList<OutputItemModel> listRelation = null;
            OutputItemModel offerItem = null;
            OutputImageModel imageItem = null;
            OutputItemModel itemRelation = null;
            StorageFileCom storageFileCom = null;

            // Variable initialize
            responseModel = new InitResponseModel();
            details = new OutputDetailsModel();
            listImages = new List<OutputImageModel>();
            listOfferItems = new List<OutputItemModel>();
            listRelation = new List<OutputItemModel>();
            storageFileCom = new StorageFileCom();

            // Get value
            var item = resultObject.Item;

            details.ItemCd = DataHelper.ToString(item.ItemCd);
            details.ItemName = DataHelper.ToString(item.ItemName);
            details.CategoryCd = DataHelper.ToString(item.CategoryCd);
            details.CategoryName = DataHelper.ToString(item.Category.CategoryName);
            details.ItemImage = DataHelper.ToString(item.ItemImage);
            foreach (var obj in item.ItemImages)
            {
                imageItem = new OutputImageModel();
                imageItem.ItemCd = DataHelper.ToString(item.ItemCd);
                imageItem.ItemImage = DataHelper.ToString(obj.FileName);
                listImages.Add(imageItem);
            }
            details.ListImages = listImages;
            details.ItemDiv = DataHelper.ToString(item.ItemDiv);
            details.OfferDiv = DataHelper.ToString(item.OfferDiv);
            details.Price = DataHelper.ToString(Formats.CURRENCY, item.SalesPrice);
            details.PriceOld = DataHelper.ToString(Formats.CURRENCY, item.SalesPriceOld);
            details.BrandCd = DataHelper.ToString(item.BrandCd);
            details.BrandName = DataHelper.ToString(item.Brand.BrandName);
            details.BrandInfo = DataHelper.ToString(item.Brand.Notes);
            details.CountryCd = DataHelper.ToString(item.CountryCd);
            details.CountryName = DataHelper.ToString(item.Country.CountryName);
            details.AgeName = DataHelper.ToString(item.Age.AgeName);
            details.LinkVideo = DataHelper.ToString(item.LinkVideo);
            details.Material = DataHelper.ToString(item.Material);
            details.Notes = DataHelper.ToString(item.Notes);
            foreach (var obj in item.ListOfferItems)
            {
                offerItem = new OutputItemModel();
                offerItem.ItemCd = DataHelper.ToString(obj.OfferItemCd);
                offerItem.ItemName = DataHelper.ToString(obj.Item.ItemName);
                var storageFile = storageFileCom.GetSingle(obj.Item.FileId, true);
                var itemImage = storageFile != null ? storageFile.FileName : "default.jpg";
                offerItem.ItemImage = DataHelper.ToString(itemImage);
                offerItem.Quantity = DataHelper.ToString(Formats.NUMBER, obj.OfferItemQtty);
                listOfferItems.Add(offerItem);
            }
            details.ListOfferItems = listOfferItems;
            foreach (var obj in resultObject.ListRelation)
            {
                itemRelation = new OutputItemModel();
                itemRelation.ItemCd = DataHelper.ToString(obj.ItemCd);
                itemRelation.ItemName = DataHelper.ToString(obj.ItemName);
                itemRelation.ItemImage = DataHelper.ToString(obj.ItemImage);
                itemRelation.ItemDiv = DataHelper.ToString(obj.ItemDiv);
                itemRelation.OfferDiv = DataHelper.ToString(obj.OfferDiv);
                itemRelation.Price = DataHelper.ToString(Formats.CURRENCY, obj.SalesPrice);
                itemRelation.PriceOld = DataHelper.ToString(Formats.CURRENCY, obj.SalesPriceOld);
                listRelation.Add(itemRelation);
            }
            details.ListRelation = listRelation;
            details.Hotline = DataHelper.ToString(resultObject.Hotline);
            // Set value
            responseModel.Details = new List<OutputDetailsModel>() { details };

            // Return value
            return responseModel;
        }
Beispiel #6
0
        /// <summary>
        /// Upload infomation
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private UploadDataModel UploadInfo(UploadDataModel inputObject)
        {
            // Local variable declaration
            UploadDataModel getResult = null;
            StorageFileCom storageFileCom = null;

            // Variable initialize
            getResult = new UploadDataModel();
            storageFileCom = new StorageFileCom();

            // Get data
            var fileId = inputObject.FileId;
            var maxFileNo = storageFileCom.GetMaxFileNo(fileId);

            // Set data
            var param = new StorageFile();
            param.FileId = fileId;
            param.FileNo = maxFileNo + 1;
            param.FileName = DataHelper.GetUniqueKey() + ".jpg";
            param.FileGroup = inputObject.FileGroup;
            param.SortKey = inputObject.SortKey;

            // Upload data
            // Upload Full size
            var path = string.Format("/pages/media/images/{0}/{1}/{2}",
                    inputObject.FileGroup, "zoom", param.FileName);
            UploadHelper.UploadImage(inputObject.InputStream, path);

            // Upload Fix size
            var uploadList = StorageFileCom.MapImageSize[param.FileGroup];
            foreach (var obj in uploadList)
            {
                path = string.Format("/pages/media/images/{0}/{1}/{2}",
                    inputObject.FileGroup, obj.SizeName, param.FileName);
                UploadHelper.UploadImage(inputObject.InputStream, obj.Width, obj.Height, path);
            }

            // Insert data
            storageFileCom.Insert(param);

            // Submit data
            storageFileCom.SubmitChanges();

            // Return value
            return getResult;
        }
Beispiel #7
0
        /// <summary>
        /// Update data
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private UpdateDataModel UpdateInfo(UpdateDataModel inputObject)
        {
            // Local variable declaration
            UpdateDataModel getResult = null;
            StorageFileCom storageFileCom = null;

            // Variable initialize
            getResult = new UpdateDataModel();
            storageFileCom = new StorageFileCom();

            // Get data
            foreach (var obj in inputObject.ListFiles)
            {
                storageFileCom.UpdateSortKey(obj, true);
            }

            // Submit data
            storageFileCom.SubmitChanges();

            // Return value
            return getResult;
        }
Beispiel #8
0
        /// <summary>
        /// Execute convert ouput.
        /// </summary>
        /// <param name="resultObject">DataModel</param>
        /// <returns>ResponseModel</returns>
        private InitResponseModel Convert(InitDataModel resultObject)
        {
            // Local variable declaration
            InitResponseModel responseModel = null;
            IList<OutputBannerModel> listBanners = null;
            IList<OutputItemModel> listNewItems = null;
            IList<OutputItemModel> listHotItems = null;
            IList<OutputItemModel> listOfferItems = null;
            OutputBannerModel banner = null;
            OutputItemModel newItem = null;
            OutputItemModel hotItem = null;
            OutputItemModel offerItem = null;
            StorageFileCom storageFileCom = null;

            // Variable initialize
            responseModel = new InitResponseModel();
            listBanners = new List<OutputBannerModel>();
            listNewItems = new List<OutputItemModel>();
            listHotItems = new List<OutputItemModel>();
            listOfferItems = new List<OutputItemModel>();
            storageFileCom = new StorageFileCom();

            // Get value
            foreach (var obj in resultObject.ListBanners)
            {
                banner = new OutputBannerModel();

                banner.BannerCd = DataHelper.ToString(obj.BannerCd);
                banner.BannerName = DataHelper.ToString(obj.BannerName);
                banner.Image = DataHelper.ToString(storageFileCom.GetFileName(obj.FileId, false));
                banner.OfferGroupCd = DataHelper.ToString(obj.OfferGroupCd);

                listBanners.Add(banner);
            }

            foreach (var obj in resultObject.ListNewItems)
            {
                newItem = new OutputItemModel();
                newItem.ItemCd = DataHelper.ToString(obj.ItemCd);
                newItem.ItemName = DataHelper.ToSubString(obj.ItemName, 20, false);
                newItem.Tooltip = DataHelper.ToString(obj.ItemName);
                newItem.ItemImage = DataHelper.ToString(obj.ItemImage);
                newItem.BrandCd = DataHelper.ToString(obj.BrandCd);
                newItem.BrandName = DataHelper.ToString(obj.Brand.BrandName);
                newItem.ItemDiv = DataHelper.ToString(obj.ItemDiv);
                newItem.OfferDiv = DataHelper.ToString(obj.OfferDiv);
                newItem.Price = DataHelper.ToString(Formats.CURRENCY, obj.SalesPrice);
                newItem.PriceOld = DataHelper.ToString(Formats.CURRENCY, obj.SalesPriceOld);
                newItem.Notes = DataHelper.ToString(obj.Notes);

                listNewItems.Add(newItem);
            }

            foreach (var obj in resultObject.ListHotItems)
            {
                hotItem = new OutputItemModel();

                hotItem.ItemCd = DataHelper.ToString(obj.ItemCd);
                hotItem.ItemName = DataHelper.ToSubString(obj.ItemName, 20, false);
                hotItem.Tooltip = DataHelper.ToString(obj.ItemName);
                hotItem.ItemImage = DataHelper.ToString(obj.ItemImage);
                hotItem.BrandCd = DataHelper.ToString(obj.BrandCd);
                hotItem.BrandName = DataHelper.ToString(obj.Brand.BrandName);
                hotItem.ItemDiv = DataHelper.ToString(obj.ItemDiv);
                hotItem.OfferDiv = DataHelper.ToString(obj.OfferDiv);
                hotItem.Price = DataHelper.ToString(Formats.CURRENCY, obj.SalesPrice);
                hotItem.PriceOld = DataHelper.ToString(Formats.CURRENCY, obj.SalesPriceOld);
                hotItem.Notes = DataHelper.ToString(obj.Notes);

                listHotItems.Add(hotItem);
            }

            foreach (var obj in resultObject.ListOfferItems)
            {
                offerItem = new OutputItemModel();

                offerItem.ItemCd = DataHelper.ToString(obj.ItemCd);
                offerItem.ItemName = DataHelper.ToSubString(obj.ItemName, 20, false);
                offerItem.Tooltip = DataHelper.ToString(obj.ItemName);
                offerItem.ItemImage = DataHelper.ToString(obj.ItemImage);
                offerItem.BrandCd = DataHelper.ToString(obj.BrandCd);
                offerItem.BrandName = DataHelper.ToString(obj.Brand.BrandName);
                offerItem.ItemDiv = DataHelper.ToString(obj.ItemDiv);
                offerItem.OfferDiv = DataHelper.ToString(obj.OfferDiv);
                offerItem.Price = DataHelper.ToString(Formats.CURRENCY, obj.SalesPrice);
                offerItem.PriceOld = DataHelper.ToString(Formats.CURRENCY, obj.SalesPriceOld);
                offerItem.Notes = DataHelper.ToString(obj.Notes);

                listOfferItems.Add(offerItem);
            }

            // Set value
            responseModel.DiscountMember = DataHelper.ToString(Formats.PERCENT, resultObject.DiscountMember);
            responseModel.Hotline = DataHelper.ToString(resultObject.Hotline);
            //responseModel.ChatYahooIM = DataHelper.GetYahooIM(resultObject.ChatYahoo);
            //responseModel.ChatSkypeIM = DataHelper.GetSkypeIM(resultObject.ChatSkype);
            //responseModel.ChatYahooIcon = DataHelper.GetYahooIcon(resultObject.ChatYahoo);
            //responseModel.ChatSkypeIcon = DataHelper.GetSkypeIcon(resultObject.ChatSkype);
            responseModel.ListBanners = listBanners;
            responseModel.ListNewItems = listNewItems;
            responseModel.ListHotItems = listHotItems;
            responseModel.ListOfferItems = listOfferItems;

            // Return value
            return responseModel;
        }
Beispiel #9
0
        /// <summary>
        /// Get infomation
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private InitDataModel GetInfo(InitDataModel inputObject)
        {
            // Local variable declaration
            InitDataModel getResult = null;
            StorageFileCom storageFileCom = null;

            // Variable initialize
            getResult = new InitDataModel();
            storageFileCom = new StorageFileCom();

            // Get data
            var listFiles = storageFileCom.GetList(inputObject.FileId, false);

            // Set value
            getResult.FileId = inputObject.FileId;
            getResult.FileGroup = inputObject.FileGroup;
            getResult.ListFiles = listFiles;

            // Return value
            return getResult;
        }