Пример #1
0
        public string GetListOfPopup()
        {
            try
            {
                List <tb_popup> lstPopupModel = new List <tb_popup>();
                lstPopupModel = _popupDAO.GetListOfPopup();

                PopupModel        popupModel;
                List <PopupModel> lstPopup = new List <PopupModel>();
                for (int i = 0; i < lstPopupModel.Count; i++)
                {
                    popupModel         = new PopupModel();
                    popupModel.PopupID = lstPopupModel[i].popup_id;
                    popupModel.Name    = lstPopupModel[i].name;
                    lstPopup.Add(popupModel);
                }

                return(JsonConvert.SerializeObject(lstPopup));
            }
            catch (Exception ex)
            {
                log.Error("BussicnessLogic => AddProduct" + ex.Message);
                return(null);
            }
        }
Пример #2
0
        public int AddNewPopupLogic(string stringJSON)
        {
            try
            {
                log.Info("BusinessLogic => AddPopup - Begin");
                PopupModel productModel = JsonConvert.DeserializeObject <PopupModel>(stringJSON);
                //TODO Printer ID

                List <string> lstName        = new List <string>();
                List <float>  lstPrice       = new List <float>();
                List <string> lstImageBase64 = new List <string>();
                List <string> lstImagePath   = new List <string>();



                for (int i = 0; i < productModel.ListSubPopup.Count; i++)
                {
                    lstName.Add(productModel.ListSubPopup[i].Name);
                    lstPrice.Add(productModel.ListSubPopup[i].Price);
                    lstImageBase64.Add(productModel.ListSubPopup[i].Image64);
                }


                if (!Directory.Exists(IMAGE_FOLDER))
                {
                    Directory.CreateDirectory(IMAGE_FOLDER);
                }

                string imagePath;

                for (int i = 0; i < lstImageBase64.Count; i++)
                {
                    if (lstImageBase64[i] == "")
                    {
                        lstImagePath.Add(@"Resources/Images/Icons/Cancel.png");
                        continue;
                    }


                    long  GUID  = DateTime.Now.Ticks;
                    Image image = ConvertImage.StringToImage(lstImageBase64[i]);

                    Bitmap bitmap = new Bitmap(image);

                    imagePath = IMAGE_FOLDER + GUID + "_" + i + ".jpg";
                    bitmap.Save(imagePath);
                    lstImagePath.Add(imagePath);
                }

                return(_popupDAO.AddPopup(productModel.Name, lstName, lstPrice, lstImagePath));
            }
            catch (Exception ex)
            {
                log.Error("BussicnessLogic => AddProduct" + ex.Message);
                return(-1);
            }
        }
Пример #3
0
        public string GetPopupDetail(int PopupID)
        {
            try
            {
                List <DataTable> lstDataTables = new List <DataTable>();
                List <ListPopup> lstPopup      = new List <ListPopup>();
                ListPopup        popupDetail   = new ListPopup();
                PopupModel       popupModel    = new PopupModel();

                lstDataTables = _popupDAO.GetPopupDetail(PopupID);

                //lstDataTables Index 0 = Main Popup
                foreach (DataRow row in lstDataTables[0].Rows)
                {
                    popupModel         = new PopupModel();
                    popupModel.PopupID = (int)row["popup_id"];
                    popupModel.Name    = row["name"].ToString();
                }

                //lstDataTables Index 1 = Sup Popup
                foreach (DataRow row in lstDataTables[1].Rows)
                {
                    lstPopup    = new List <ListPopup>();
                    popupDetail = new ListPopup();

                    popupDetail.SubPopUpID = (int)row["popup_item_id"];
                    popupDetail.Name       = row["name"].ToString();
                    popupDetail.Price      = (float)row["price"];
                    popupDetail.Image64    = row["image_path"].ToString();
                    lstPopup.Add(popupDetail);
                }

                popupModel.ListSubPopup = new List <ListPopup>();
                popupModel.ListSubPopup = lstPopup;

                string stringJSON = JsonConvert.SerializeObject(popupModel);

                return(stringJSON);
            }
            catch (Exception ex)
            {
                log.Error("BussicnessLogic => AddProduct" + ex.Message);
                return(null);
            }
        }
Пример #4
0
        public int UpdatePopup(string stringJSON)
        {
            try
            {
                PopupModel popupModel = JsonConvert.DeserializeObject <PopupModel>(stringJSON);

                List <int>    lstSubpPopupID       = new List <int>();
                List <string> lstSubPopupName      = new List <string>();
                List <float>  lstSubPopupPrice     = new List <float>();
                List <string> lstSubpopupImagePath = new List <string>();

                lstSubpPopupID       = popupModel.ListSubPopup.Select(x => x.SubPopUpID).ToList();
                lstSubPopupName      = popupModel.ListSubPopup.Select(x => x.Name).ToList();
                lstSubPopupPrice     = popupModel.ListSubPopup.Select(x => x.Price).ToList();
                lstSubpopupImagePath = popupModel.ListSubPopup.Select(x => x.Image64).ToList();

                return(_popupDAO.UpdatePopup(popupModel.PopupID, popupModel.Name, lstSubpPopupID, lstSubPopupName, lstSubPopupPrice, lstSubpopupImagePath));
            }
            catch (Exception ex)
            {
                log.Error("BussicnessLogic => AddProduct" + ex.Message);
                return(-1);
            }
        }