예제 #1
0
 public override APIResponse Insert(ICardDetails CardDetailsObj)
 {
     try
     {
         AESObj.GenerateKey();
         CardDetailsObj.SetIV(AESObj.GetIV());
         CardDetailsObj.SetDecryptionKey(AESObj.GetKey());
         CardDetailsObj.SetName(AESObj.Encrypt(CardDetailsObj.GetName()));
         CardDetailsObj.SetCardNumber(AESObj.Encrypt(CardDetailsObj.GetCardNumber()));
         CardDetailsObj.SetExpiryMonth(AESObj.Encrypt(CardDetailsObj.GetExpiryMonth()));
         CardDetailsObj.SetExpiryYear(AESObj.Encrypt(CardDetailsObj.GetExpiryYear()));
         CardDetailsObj.SetCvv(AESObj.Encrypt(CardDetailsObj.GetCvv()));
         bool Response = new Security(UserProfileObj).AuthenticateUser();
         if (Response == true)
         {
             if (0 == CardDetailsDataLayerObj.Insert(CardDetailsObj))
             {
                 return(APIResponse.NOT_OK);
             }
             else
             {
                 return(APIResponse.OK);
             }
         }
         else
         {
             return(APIResponse.NOT_AUTHENTICATED);
         }
     }
     catch (NullReferenceException nex)
     {
         Logger.Instance().Log(Warn.Instance(), new LogInfo("Received null reference while adding card (Routine : AuthenticateUser), might be token manipulation. Check token : " + UserProfileObj.GetToken()));
         throw nex;
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #2
0
        public void InsertValuesToDatabase(int Oid, int Pbsid, int Quantity, double Price, double TaxAmount)
        {
            string Source = "sp_insertOrderByRow";

            try
            {
                object[] paramToken =
                {
                    new MySqlParameter("@paramoID",       Oid),
                    new MySqlParameter("@parampbsID",     Pbsid),
                    new MySqlParameter("@paramQuantity",  Quantity),
                    new MySqlParameter("@paramPrice",     Price),
                    new MySqlParameter("@paramTaxAmount", TaxAmount)
                };
                MySQLCommands.Instance().ExecuteQuery(Source, CommandType.StoredProcedure, paramToken);
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                throw ex;
            }
        }
예제 #3
0
 public override DateTime BuildOrderDate()
 {
     try
     {
         string OrderDateTimeStr = null;
         OrderDetailsDataLayer OrderDetailsDataLayerObj = new OrderDetailsDataLayer(UserProfileObj, OrderObj);
         DataSet Output = OrderDetailsDataLayerObj.FetchOrderDetailsByType();
         foreach (DataRow dr in Output.Tables[0].Rows)
         {
             if (int.Parse(dr["oId"].ToString()) == OrderObj.GetOrderID())
             {
                 OrderDateTimeStr = DateTime.Parse(dr["date"].ToString()).ToString();
             }
         }
         return(DateTime.Parse(OrderDateTimeStr));
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #4
0
 public override int Delete(IStores StoreObj)
 {
     Source = "sp_RemoveStore";
     try
     {
         object[] param =
         {
             new MySqlParameter("@paramSID", StoreObj.GetStoreID())
         };
         return(Commands.ExecuteNonQuery(Source, CommandType.StoredProcedure, param));
     }
     catch (MySqlException mse)
     {
         Logger.Instance().Log(Fatal.Instance(), mse);
         throw mse;
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #5
0
 public override double BuildOrderAmount()
 {
     try
     {
         double OrderAmount = 0;
         OrderDetailsDataLayer OrderDetailsDataLayerObj = new OrderDetailsDataLayer(UserProfileObj, OrderObj);
         DataSet Output = OrderDetailsDataLayerObj.FetchOrderDetailsByType();
         foreach (DataRow dr in Output.Tables[0].Rows)
         {
             if (int.Parse(dr["oId"].ToString()) == OrderObj.GetOrderID())
             {
                 OrderAmount = double.Parse(dr["Amount"].ToString());
             }
         }
         return(OrderAmount);
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #6
0
 public override string BuildOrderStatus()
 {
     try
     {
         string Status = null;
         OrderDetailsDataLayer OrderDetailsDataLayerObj = new OrderDetailsDataLayer(UserProfileObj, OrderObj);
         DataSet Output = OrderDetailsDataLayerObj.FetchOrderDetailsByType();
         foreach (DataRow dr in Output.Tables[0].Rows)
         {
             if (int.Parse(dr["oId"].ToString()) == OrderObj.GetOrderID())
             {
                 Status = dr["statusName"].ToString();
             }
         }
         return(Status);
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #7
0
 public override List <ICardDetails> Select()
 {
     try
     {
         bool Response = new Security(UserProfileObj).AuthenticateUser();
         if (Response == true)
         {
             List <ICardDetails> DecryptedCardDetailsList = new List <ICardDetails>();
             foreach (ICardDetails EncryptedCardObj in CardDetailsDataLayerObj.Select())
             {
                 ICardDetails DecryptedCardDetails = new CardDetails();
                 AESObj.SetIV(EncryptedCardObj.GetIV());
                 AESObj.SetKey(EncryptedCardObj.GetDecryptionKey());
                 DecryptedCardDetails.SetCardID(EncryptedCardObj.GetCardID());
                 DecryptedCardDetails.SetName(AESObj.Decrypt(EncryptedCardObj.GetName()));
                 DecryptedCardDetails.SetCardNumber(AESObj.Decrypt(EncryptedCardObj.GetCardNumber()).ToString());
                 DecryptedCardDetails.SetExpiryMonth(AESObj.Decrypt(EncryptedCardObj.GetExpiryMonth()));
                 DecryptedCardDetails.SetExpiryYear(AESObj.Decrypt(EncryptedCardObj.GetExpiryYear()));
                 DecryptedCardDetails.SetCvv(AESObj.Decrypt(EncryptedCardObj.GetCvv()));
                 DecryptedCardDetailsList.Add(DecryptedCardDetails);
             }
             return(DecryptedCardDetailsList);
         }
         else
         {
             return(null);
         }
     }
     catch (NullReferenceException nex)
     {
         Logger.Instance().Log(Warn.Instance(), new LogInfo("Received null reference while fetching card details (Routine : AuthenticateUser), might be token manipulation. Check token : " + UserProfileObj.GetToken()));
         throw nex;
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #8
0
        public override int Update(IProduct ProductsOnlyObj)
        {
            Source = "sp_ModifyProductOnly";
            int    ProductId       = ProductsOnlyObj.GetProductId();
            string ProductNewName  = ProductsOnlyObj.GetProductName();
            string ProductNewImage = ProductsOnlyObj.GetProductImage();

            try
            {
                Object[] param =
                {
                    new MySqlParameter("@paramPID",             ProductId),
                    new MySqlParameter("@paramProductNewName",  ProductNewName),
                    new MySqlParameter("@paramProductNewImage", ProductNewImage)
                };
                return(Commands.ExecuteNonQuery(Source, CommandType.StoredProcedure, param));
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                throw ex;
            }
        }
예제 #9
0
        public DataSet FetchOtherStoresList(int PBSID)
        {
            string Source = "sp_FetchOtherStoresThanLowestProductStoreByPBSID";

            try
            {
                object[] param =
                {
                    new MySqlParameter("@paramPBSID", PBSID)
                };
                return(MySQLCommands.Instance().ExecuteQuery(Source, CommandType.StoredProcedure, param));
            }
            catch (MySqlException mse)
            {
                Logger.Instance().Log(Fatal.Instance(), mse);
                throw mse;
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                throw ex;
            }
        }
예제 #10
0
        public IOrderCreaterStatus CreateOrder(IAddress AddressObj, ICardDetails CardObj, IUserProfile UserProfileObj, ICart CartObj)
        {
            try
            {
                TaxManagement       TaxManagementObj = new TaxManagement();
                int                 orderID          = int.Parse(new OrderCreatorDataLayer().CreateOrderID(AddressObj, CardObj, UserProfileObj).Tables[0].Rows[0]["OrderID"].ToString());
                List <ITaxProducts> ProductList      = TaxManagementObj.CalculateTaxByProduct(CartObj, AddressObj, UserProfileObj);
                // insert all the values to the database
                OrderCreatorDataLayer OrderDataLayerObj = new OrderCreatorDataLayer();
                foreach (CartItems Items in CartObj.GetCartItems())
                {
                    OrderDataLayerObj.InsertValuesToDatabase(orderID, Items.ProductObj.pbsID, Items.ProductObj.Quantity, Items.ProductObj.Price, TaxManagementObj.GetTaxAmount(Items.ProductObj.pbsID, ProductList));
                }

                IOrderCreaterStatus ResponseObj = new OrderCreaterStatus(true, orderID);
                return(ResponseObj);
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                throw ex;
            }
        }
예제 #11
0
 public string Decrypt(string encryptedText)
 {
     try
     {
         RijndaelManaged aesEncryption = new RijndaelManaged
         {
             KeySize   = 256,
             BlockSize = 128,
             Mode      = CipherMode.CBC,
             Padding   = PaddingMode.PKCS7,
             IV        = Convert.FromBase64String(IV),
             Key       = Convert.FromBase64String(Key)
         };
         ICryptoTransform decrypto       = aesEncryption.CreateDecryptor();
         byte[]           encryptedBytes = Convert.FromBase64CharArray(encryptedText.ToCharArray(), 0, encryptedText.Length);
         return(ASCIIEncoding.UTF8.GetString(decrypto.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length)));
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ApiAuthResponse AuthResponseObj = new ApiAuthResponse();

        try
        {
            UserProfile UserProfileObj          = new UserProfile(Token: CookieProxy.Instance().GetValue("t").ToString(), Email: Request.Form["e"].ToString());
            UserTemplate <IUserProfile> Profile = new AdminUserTemplate(UserProfileObj);
            APIResponse ResponseObj             = Profile.Add();
            AuthResponseObj.SetAPIResponse(ResponseObj);
            if (ResponseObj == APIResponse.OK)
            {
                // log the event
                Logger.Instance().Log(Info.Instance(), new LogInfo(Profile.FetchParticularProfile(UserProfileObj).GetEmail() + " added " + Request.Form["e"]));
            }
        }
        catch (Exception ex)
        {
            AuthResponseObj.SetAPIResponse(APIResponse.NOT_OK);
            Logger.Instance().Log(Fatal.Instance(), ex);
        }
        Response.Write(new JavaScriptSerializer().Serialize(AuthResponseObj));
    }
예제 #13
0
 public override APIResponse Delete(ICardDetails CardDetailsObj)
 {
     try
     {
         bool AuthUserResponseObj = new Security(UserProfileObj).AuthenticateUser();
         if (AuthUserResponseObj == true)
         {
             if (0 == CardDetailsDataLayerObj.Delete(CardDetailsObj))
             {
                 return(APIResponse.NOT_OK);
             }
             else
             {
                 return(APIResponse.OK);
             }
         }
         else
         {
             return(APIResponse.NOT_AUTHENTICATED);
         }
     }
     catch (NullReferenceException nex)
     {
         Logger.Instance().Log(Warn.Instance(), new LogInfo("Received null reference while removing card (Routine : AuthenticateUser), might be token manipulation. Check token : " + UserProfileObj.GetToken()));
         throw nex;
     }
     catch (MySqlException mse)
     {
         Logger.Instance().Log(Warn.Instance(), mse);
         throw mse;
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
 public override APIResponse Delete(IStores StoreObj)
 {
     try
     {
         bool Response = new Security(UserProfileObj).AuthenticateAdmin();
         if (Response == true)
         {
             if (0 == StoresTemplateObj.Delete(StoreObj))
             {
                 return(APIResponse.NOT_OK);
             }
             else
             {
                 return(APIResponse.OK);
             }
         }
         else
         {
             return(APIResponse.NOT_AUTHENTICATED);
         }
     }
     catch (NullReferenceException nex)
     {
         Logger.Instance().Log(Warn.Instance(), new LogInfo("Received null reference while removing store (Routine : AuthenticateAdmin), might be token manipulation. Check token : " + UserProfileObj.GetToken()));
         throw nex;
     }
     catch (MySqlException mse)
     {
         Logger.Instance().Log(Warn.Instance(), mse);
         throw mse;
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #15
0
        public override List <IUserProfile> FetchList()
        {
            Source = "sp_searchUserList";
            string Token = UserProfileObj.GetToken();

            if (null == Query || Query.ToString().Length == 0)
            {
                throw new ArgumentException("Invalid parameter : Given Query Value is null");
            }
            try
            {
                Object[] param =
                {
                    new MySqlParameter("@paramToken",       Token.ToString()),
                    new MySqlParameter("@paramSearchQuery", Query)
                };
                DataSet             Output   = Commands.ExecuteQuery(Source, CommandType.StoredProcedure, param);
                List <IUserProfile> UserList = new List <IUserProfile>();
                foreach (DataRow dr in Output.Tables[0].Rows)
                {
                    UserProfile Profile = new UserProfile
                                          (
                        FirstName: dr["firstName"].ToString(),
                        LastName: dr["lastName"].ToString(),
                        Email: dr["email"].ToString(),
                        IsAdmin: dr["roleName"].ToString().ToLower() == "admin" ? true : false
                                          );
                    UserList.Add(Profile);
                }
                return(UserList);
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                throw ex;
            }
        }
예제 #16
0
 public override List <IOrderBuilderResponse> BuildOrder()
 {
     try
     {
         List <IOrderBuilderResponse> Orders = new List <IOrderBuilderResponse>();
         // fetching Order IDs
         DataSet OrdersID = new OrderDetailsDataLayer(UserProfileObj, OrderObj).FetchOrderDetailsByType();
         foreach (DataRow dr in OrdersID.Tables[0].Rows)
         {
             IOrderBuilderResponse BuilderResponseObj = new OrderBuilderResponse();
             int OrderId = int.Parse(dr["oId"].ToString());
             OrderObj.SetOrderID(OrderId);
             List <string>        StoreLogoList   = new List <string>();
             OrderBuilderAbstract OrderBuilderObj = new OrderBuilder(UserProfileObj, OrderObj);
             StoreLogoList = OrderBuilderObj.BuildOrderStores();
             DateTime OrderDate      = OrderBuilderObj.BuildOrderDate();
             int      CurrentOrderId = OrderBuilderObj.BuildOrderId();
             int      ItemCount      = OrderBuilderObj.BuildOrderItemCount();
             double   OrderAmount    = OrderBuilderObj.BuildOrderAmount();
             string   Status         = OrderBuilderObj.BuildOrderStatus();
             BuilderResponseObj.SetStoreLogo(StoreLogoList);
             BuilderResponseObj.SetOrderDate(OrderDate);
             BuilderResponseObj.SetOrderID(CurrentOrderId);
             BuilderResponseObj.SetOrderItemCount(ItemCount);
             BuilderResponseObj.SetOrderAmount(OrderAmount);
             BuilderResponseObj.SetOrderStatus(Status);
             Orders.Add(BuilderResponseObj);
         }
         return(Orders);
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #17
0
        public override int Delete(IOrder OrderObj)
        {
            Source = "sp_RemoveOrder";
            int OrderID = OrderObj.GetOrderID();

            try
            {
                Object[] param =
                {
                    new MySqlParameter("@paramOID", OrderID)
                };
                return(Commands.ExecuteNonQuery(Source, CommandType.StoredProcedure, param));
            }
            catch (MySqlException mse)
            {
                Logger.Instance().Log(Fatal.Instance(), mse);
                throw mse;
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                throw ex;
            }
        }
예제 #18
0
 public List <ITaxProducts> CalculateTaxByProduct(ICart cartObj, IAddress AddressObj, IUserProfile UserProfile)
 {
     try
     {
         List <ITaxProducts> ProductList = new List <ITaxProducts>();
         ISecurity           Security    = new Security(UserProfile);
         if (Security.AuthenticateUser() == true)
         {
             DataSet TaxDS     = new TaxManagementDataLayer().GetTaxDetailsFromDB(AddressObj.GetAddressID());
             double  TaxFromDB = Math.Round(double.Parse(TaxDS.Tables[0].Rows[0]["Tax"].ToString()), 2);
             foreach (CartItems Items in cartObj.GetCartItems())
             {
                 double TotalAmount = Math.Round(Items.ProductObj.Price * Items.ProductObj.Quantity * 0.01 * TaxFromDB, 2);
                 ProductList.Add(new TaxProduct(Items.ProductObj.pbsID, TotalAmount));
             }
         }
         return(ProductList);
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #19
0
        public override int Delete(IProduct ProductsOnlyObj)
        {
            Source = "sp_RemoveProductOnly";
            int ProductId = ProductsOnlyObj.GetProductId();

            try
            {
                Object[] param =
                {
                    new MySqlParameter("@paramPID", ProductId)
                };
                return(Commands.ExecuteNonQuery(Source, CommandType.StoredProcedure, param));
            }
            catch (MySqlException mse)
            {
                Logger.Instance().Log(Fatal.Instance(), mse);
                throw mse;
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                throw ex;
            }
        }
예제 #20
0
        public void GenerateKey()
        {
            try
            {
                RijndaelManaged aesEncryption = new RijndaelManaged
                {
                    KeySize   = 256,
                    BlockSize = 128,
                    Mode      = CipherMode.CBC,
                    Padding   = PaddingMode.PKCS7
                };
                aesEncryption.GenerateIV();
                aesEncryption.GenerateKey();

                // get the iv and key
                IV  = Convert.ToBase64String(aesEncryption.IV);
                Key = Convert.ToBase64String(aesEncryption.Key);
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                throw ex;
            }
        }
예제 #21
0
 public override List <ICategory> Select()
 {
     Source = "sp_FetchCategory";
     // Category fetching stored procedure
     try
     {
         Object[]         param        = null;
         DataSet          Output       = Commands.ExecuteQuery(Source, CommandType.StoredProcedure, param);
         List <ICategory> CategoryList = new List <ICategory>();
         foreach (DataRow dr in Output.Tables[0].Rows)
         {
             ICategory Category = new Category();
             Category.SetCategoryId(Int32.Parse(dr["cID"].ToString()));
             Category.SetCategoryName(dr["categoryName"].ToString());
             CategoryList.Add(Category);
         }
         return(CategoryList);
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #22
0
 public override List <IStores> Select()
 {
     Source = "sp_FetchStores";
     // To fetch Stores list
     try
     {
         DataSet        Output    = Commands.ExecuteQuery(Source, CommandType.StoredProcedure, null);
         List <IStores> StoreList = new List <IStores>();
         foreach (DataRow dr in Output.Tables[0].Rows)
         {
             IStores StoreObj = new Stores();
             StoreObj.SetStoreID(int.Parse(dr["sID"].ToString()));
             StoreObj.SetStoreName(dr["storeName"].ToString());
             StoreObj.SetStoreLogo(dr["storeLogo"].ToString());
             StoreList.Add(StoreObj);
         }
         return(StoreList);
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #23
0
 public override List <String> BuildOrderStores()
 {
     try
     {
         List <string>          StoreLogoList            = new List <string>();
         IOrderDetailsDataLayer OrderDetailsDataLayerObj = new OrderDetailsDataLayer(UserProfileObj, OrderObj);
         DataSet Output = OrderDetailsDataLayerObj.FetchOrderDetailsByType();
         foreach (DataRow dr in Output.Tables[1].Rows)
         {
             if (int.Parse(dr["oId"].ToString()) == OrderObj.GetOrderID())
             {
                 IStores StoreImageObj = new Stores();
                 StoreImageObj.SetStoreLogo(dr["storeLogo"].ToString());
                 StoreLogoList.Add(StoreImageObj.GetStoreLogo());
             }
         }
         return(StoreLogoList);
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #24
0
 public override List <IUserProfile> FetchList()
 {
     try
     {
         bool AResponse = new Security(UserProfileObj).AuthenticateUser();
         if (AResponse == true)
         {
             // replacing the spaces of the query with | (used for REGEXP in MySQL)
             Query = Query.Replace(' ', '|');
             UserDataLayerTemplate = new DATALAYER.NormalUserTemplate(UserProfileObj, Query);
             List <IUserProfile> profiles = UserDataLayerTemplate.FetchList();
             return(profiles);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
 /// <inheritdoc />
 void IInteractiveLogger.Fatal(Exception exception)
 {
     Fatal?.Invoke(exception.ToString());
 }
 /// <inheritdoc />
 void IInteractiveLogger.Fatal(string message)
 {
     Fatal?.Invoke(message);
 }
예제 #27
0
        public ProductResponse FetchProducts(string Query)
        {
            // Instance the response
            ProductResponse response = new ProductResponse();

            try
            {
                response.KeywordSearch = Query;
                // replace spaces by | for regexp to process multiple keywords in MYSQL
                Query = Query.Replace(' ', '|');
                DataSet output = new ProductTemplate().FetchAllProducts(Query);
                // check the row count
                if (output.Tables[0].Rows.Count == 0)
                {
                    response.HasProducts    = false;
                    response.responseString = "No products available with Query : " + Query;
                }
                else
                {
                    // we have the products
                    // get the unique list of categories
                    DataView  dv = new DataView(output.Tables[0]);
                    DataTable UniqueCategories = dv.ToTable(true, "CategoryName");
                    response.HasProducts     = true;
                    response.responseString  = "SUCCESS";
                    response.TotalCategories = UniqueCategories.Rows.Count;
                    // we have the unique categories
                    response.productsByCategory = new List <Category>();
                    foreach (DataRow dr in UniqueCategories.Rows)
                    {
                        string             CategoryName          = dr["CategoryName"].ToString();
                        ProductsByCategory ProductsByCategoryObj = new ProductsByCategory();
                        ProductsByCategoryObj.SetCategoryName(CategoryName);
                        DataView dvFiltered = new DataView(output.Tables[0])
                        {
                            RowFilter = "CategoryName = '" + CategoryName + "'"
                        };

                        List <Products> ProductList = new List <Products>();
                        // from dv filtered, get all the product details
                        foreach (DataRowView FilteredRow in dvFiltered)
                        {
                            Products ProdObj = new Products
                            {
                                pbsID        = int.Parse(FilteredRow["pbsID"].ToString()),
                                ProductName  = FilteredRow["productName"].ToString(),
                                Price        = Double.Parse(FilteredRow["Price"].ToString()),
                                StoreLogo    = FilteredRow["storeLogo"].ToString(),
                                QuantityType = FilteredRow["quantityperunit"].ToString(),
                                ProductImage = FilteredRow["productImage"].ToString()
                            };
                            ProductList.Add(ProdObj);
                        }
                        ProductsByCategoryObj.SetProductList(ProductList);
                        response.productsByCategory.Add(ProductsByCategoryObj);
                    }
                }
            }
            catch (Exception ex)
            {
                // log the event
                Logger.Instance().Log(Fatal.Instance(), ex);
                response.HasProducts    = false;
                response.responseString = " Unable to fetch products this time, please try again later. This event has been logged".ToString();
                throw ex;
            }
            return(response);
        }
예제 #28
0
        public UserProfileMenuResponse GetProfileMenu(string CookieMenu)
        {
            UserProfileMenuResponse ProfileMenu = new UserProfileMenuResponse();
            bool   ShouldFetchProfileFromServer = false;
            string Token = UserProfileObj.GetToken();

            try
            {
                // check if token exists
                if (Token == null)
                {
                    ProfileMenu.IsProfileAvailable = false;
                    return(ProfileMenu);
                }
                else
                {
                    bool response = new Security(UserProfileObj).AuthenticateUser();
                    if (response == false)
                    {
                        ProfileMenu.IsProfileAvailable = false;
                        return(ProfileMenu);
                    }
                    else
                    {
                        if (CookieMenu == null)
                        {
                            ShouldFetchProfileFromServer = true;
                        }
                        else
                        {
                            ProfileMenu = new JavaScriptSerializer().Deserialize <UserProfileMenuResponse>(CookieMenu);
                            if (ProfileMenu.IsProfileAvailable == false)
                            {
                                ShouldFetchProfileFromServer = true;
                            }
                        }
                    }
                }
                // get the profile menu
                if (CookieMenu == null)
                {
                    ShouldFetchProfileFromServer = true;
                }
                else
                {
                    ProfileMenu = new JavaScriptSerializer().Deserialize <UserProfileMenuResponse>(CookieMenu);
                    if (ProfileMenu.ShouldReupdate)
                    {
                        ShouldFetchProfileFromServer = true;
                    }
                }
                if (ShouldFetchProfileFromServer)
                {
                    ProfileMenu.SetUserProfile(new NormalUserTemplate(UserProfileObj).FetchParticularProfile(UserProfileObj));
                    ProfileMenu.IsProfileAvailable = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                ProfileMenu.IsProfileAvailable = false;
                throw ex;
            }

            return(ProfileMenu);
        }
예제 #29
0
        static void Main(string[] args)
        {
            ClassWork even = new ClassWork();

            /* ---- CW_1 ----*/
            //from main call EncodeVideo

            even.invocationMethodsList += even.SendEmailAfterEncoding;
            even.invocationMethodsList += even.SendSmsAfterEncoding;
            even.VideoEncoding("Batman movie...");

            even.invocationMethodsList -= even.SendEmailAfterEncoding;
            even.VideoEncoding("Superman movie...");

            /* ---- CW_2 ---- */

            even.toPrint += even.PrintToScreen;
            even.toPrint += even.PrintToScreenx2;

            even.RunFrom1to10();

            even.toPrint -= even.PrintToScreenx2;

            Real_Event real_event = new Real_Event();

            // +=

            real_event.invocationMethodsList += real_event.SendEmailAfterEncoding;
            real_event.invocationMethodsList += real_event.SendSmsAfterEncoding;
            real_event.invocationMethodsList += real_event.UploadInCloud;
            real_event.Mp4VideoEncoding("Batman movie...");
            real_event.SlimEncoder("Spiderman movie...");

            real_event.invocationMethodsList -= real_event.SendEmailAfterEncoding;
            real_event.MpgVideoEncoding("Superman movie...");

            /*------------------------------------------------------ 27-01-21 ------------------------------------------------------*/

            /* Проэкт BankEvents*/

            Bank               igud      = new Bank();
            Fatal              fatal     = new Fatal();
            Ariela             a         = new Ariela();
            BuyHouseCommercial buy_house = new BuyHouseCommercial();

            buy_house.Register1MWithBank(igud);
            fatal.RegisterBankWithFreeWeekend(igud);
            fatal.RegisterBankWithFreeWeekend(a);

            Customer c = new Customer
            {
                Name         = "Moshe",
                Balance      = 50000,
                MobileNumber = "055-555555555"
            };

            igud.AddCustomer(c);
            igud.Deposite(c, 999_999);

            a.PlayLotto();

            /* HW _FizzBuzz*/

            hw_FizzBuzz fb = new hw_FizzBuzz();

            fb.FizzOccured += fb.HandleFizz;
            fb.BuzzOccured += fb.HandleBuzz;
            for (int i = 1; i <= 30; i++)
            {
                Console.Write(i + ": ");
                if (i % 3 == 0)
                {
                    // fire fizz event
                    fb.FireEventFizz(i);
                }
                if (i % 5 == 0)
                {
                    // fire buzz event
                    fb.FireEventBuzz(i);
                }
                Console.WriteLine();
            }
        }
예제 #30
0
 public abstract void Visit(Fatal expression);