示例#1
0
        /// <summary>
        /// Test of the ExistsPendriveTest function
        /// </summary>
        static public void ExistsPendriveTest()
        {
            StoreBL storeBL = new StoreBL();
            Store   store   = new Store();

            store.Name = "PenStore1";
            store.ID   = "1";

            PenDrive pendrive1 = new PenDrive();

            pendrive1.Brand = "brand1";
            pendrive1.Model = "model1";
            PenDrive pendrive2 = new PenDrive();
            PenDrive pendrive3 = new PenDrive();

            storeBL.AddPenDrive(store, pendrive1);
            storeBL.AddPenDrive(store, pendrive2);
            storeBL.AddPenDrive(store, pendrive3);

            if (storeBL.ExistPenDrive(store, "brand1", "model"))
            {
                Console.WriteLine("The pen exist");
            }
            else
            {
                Console.WriteLine("The pen doesn't exist");
            }
        }
 public InvoiceController(ItemDetailsBL itemDetails, StoreBL store, InvoiceBL invoice, InvoiceDetailsBL invoiceDetails)
 {
     this._itemDetails    = itemDetails;
     this._store          = store;
     this._invoice        = invoice;
     this._invoiceDetails = invoiceDetails;
 }
        public HttpResponseMessage SendLackCreditReport(HttpRequestMessage request, [FromBody] StoreAttributes data)
        {
            PersonBL           ConsumerAuth   = new PersonBL();
            GenericApiResponse response       = new GenericApiResponse();
            StoreBL            storeBL        = new StoreBL();
            string             error          = "";
            SimpleTextResponse ReportResponse = new SimpleTextResponse();

            try
            {
                IEnumerable <string> key = null;
                request.Headers.TryGetValues("authenticationKey", out key);
                var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString());

                if (consumerFb != null)
                {
                    if (!string.IsNullOrEmpty(data.FirebaseID))
                    {
                        int?ResultOfReport = storeBL.AirTimeReporting(data.StoreName, data.AddressStore, data.Longitude, data.Latitude, data.FirebaseID, consumerFb.ConsumerID, consumerFb.RegistrationDate, consumerFb.ModificationDate, ref error);

                        if (ResultOfReport > 0)
                        {
                            ReportResponse.Message = "Operation completed succesfully";
                            ReportResponse.result  = true;

                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, ReportResponse));
                        }
                        else
                        {
                            ReportResponse.Message = "Something went wrong";
                            ReportResponse.result  = false;

                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, ReportResponse));
                        }
                    }
                    else
                    {
                        ReportResponse.Message = "Bad Request";
                        ReportResponse.result  = false;

                        return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, ReportResponse));
                    }
                }
                else
                {
                    response.HttpCode = 404;
                    response.Message  = "Facebook information not found";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                }
            }
            catch (Exception ex)
            {
                response.HttpCode = 500;
                response.Message  = "something went wrong";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
            }
        }
示例#4
0
        /// <summary>
        /// Test of the GetAllProductsTest function.
        /// </summary>
        static public void GetAllProductsTest()
        {
            StoreBL storeBL = new StoreBL();
            Store   store   = new Store();

            PenDrive pen1 = new PenDrive();

            pen1.Memory = 500;
            pen1.Model  = "Kingston";
            pen1.Price  = 20;

            PenDrive pen2 = new PenDrive();

            pen2.Memory = 300;
            pen2.Model  = "HP";
            pen2.Price  = 17;

            Phone pho1 = new Phone();

            pho1.Inches = 30;
            pho1.Model  = "HP";
            pho1.Price  = 17;

            Phone pho2 = new Phone();

            pho2.Inches = 30;
            pho2.Model  = "HP";
            pho2.Price  = 17;

            Refrigerator ref1 = new Refrigerator();

            ref1.Brand    = "Samsung";
            ref1.Capacity = 50;
            ref1.Price    = 430;

            Refrigerator ref2 = new Refrigerator();

            ref2.Brand    = "Fujitsu";
            ref2.Capacity = 100;
            ref2.Price    = 600;

            store.Products.Pendrives.Add(pen1);
            store.Products.Pendrives.Add(pen2);
            store.Products.Phones.Add(pho1);
            store.Products.Phones.Add(pho1);
            store.Products.Refrigerators.Add(ref1);
            store.Products.Refrigerators.Add(ref2);


            Console.WriteLine(storeBL.GetAllProducts(store));
        }
示例#5
0
        /// <summary>
        /// Test of the CalculateTotalPriceTest function.
        /// </summary>
        static public void CalculateTotalPriceTest()
        {
            StoreBL storeBL = new StoreBL();
            Store   store   = new Store();

            decimal?sum = 0;

            store.Name = "PenStore1";
            store.ID   = "1";

            PenDrive pendrive1 = new PenDrive();

            pendrive1.Brand = "brand1";
            pendrive1.Model = "model1";
            pendrive1.Price = 34;
            PenDrive pendrive2 = new PenDrive();

            pendrive2.Brand = "Brand2";
            pendrive2.Price = 26;
            PenDrive pendrive3 = new PenDrive();

            pendrive3.Brand = "Brand3";
            pendrive3.Price = 40;
            PenDrive pendrive4 = new PenDrive();

            pendrive4.Brand = "Brand4";
            pendrive4.Price = 76;

            storeBL.AddPenDrive(store, pendrive1);
            storeBL.AddPenDrive(store, pendrive2);
            storeBL.AddPenDrive(store, pendrive3);
            storeBL.AddPenDrive(store, pendrive4);


            if (storeBL.CalculateTotalPrice(store, store.Products.Pendrives, out sum))
            {
                Console.WriteLine("Successfully Calculated.");
            }
            else
            {
                Console.WriteLine("Not so successfully calculated.");
            }


            Console.WriteLine("Suma:" + sum.ToString());
        }
示例#6
0
        /// <summary>
        /// Gets all stores.
        /// </summary>
        /// <returns>
        /// Get All Stores
        /// </returns>
        public IEnumerable <StoreEntity> GetAllStores()
        {
            IStoreBL           storeBL = new StoreBL();
            List <StoreEntity> result  = new List <StoreEntity>();

            foreach (Store source in storeBL.GetAllStore())
            {
                StoreEntity target = new StoreEntity();
                target.StoreID          = source.StoreID;
                target.Name             = source.Name;
                target.SalesOrderNumber = source.SalesOrderNumber;
                target.OrderDate        = source.OrderDate;
                target.TotalDue         = source.TotalDue;
                result.Add(target);
            }
            return(result);
        }
示例#7
0
        public HttpResponseMessage GetStores()
        {
            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                //result.MenuList = new PermissionBL().GetMenu(SysCommon.CurrentUser.Id, SysCommon.CurrentUser.Localization);
                IList <StoreVM> list = new StoreBL().GetStoreList(Guid.NewGuid());
                response = Request.CreateResponse <IList <StoreVM> >(HttpStatusCode.OK, list);
            }
            catch (Exception ex)
            {
                LogHelper.Write(this.GetType(), ex);
                response = Request.CreateResponse <string>(HttpStatusCode.InternalServerError, ex.Message);
            }

            return(response);
        }
示例#8
0
        /// <summary>
        /// Test of the AddPenDrive function
        /// </summary>
        static public void AddPendriveTest()
        {
            StoreBL storeBL = new StoreBL();
            Store   store   = new Store();

            store.Name = "PenStore1";
            store.ID   = "1";

            PenDrive pendrive1 = new PenDrive();

            if (storeBL.AddPenDrive(store, pendrive1))
            {
                Console.WriteLine("Pendrive added.");
            }
            else
            {
                Console.WriteLine("There was a problem adding the pendrive.");
            }

            storeBL.AddPenDrive(store, pendrive1);
        }
        public HttpResponseMessage GetStoreItems(HttpRequestMessage request)
        {
            string              error           = "";
            PersonBL            ConsumerAuth    = new PersonBL();
            GameStoreResponse   storeResponse   = new GameStoreResponse();
            GameStoreInteractor storeInteractor = new GameStoreInteractor();
            GenericApiResponse  response        = new GenericApiResponse();
            StoreBL             storeBL         = new StoreBL();

            try
            {
                IEnumerable <string> AppVersion = null;
                request.Headers.TryGetValues("AppVersion", out AppVersion);

                IEnumerable <string> Platform = null;
                request.Headers.TryGetValues("Platform", out Platform);

                bool ApplyValidation = bool.Parse(ConfigurationManager.AppSettings["ApplyValidationAppVersion"].ToString());

                if (ApplyValidation == false || (AppVersion != null && Platform != null))
                {
                    string versionRequired = "";

                    var isValidVersion = (ApplyValidation == false) ? true : gameBL.IsValidAppVersion(AppVersion.FirstOrDefault(), Platform.FirstOrDefault(), ref error, ref versionRequired);

                    if (isValidVersion)
                    {
                        IEnumerable <string> key = null;
                        request.Headers.TryGetValues("authenticationKey", out key);
                        var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString());

                        if (consumerFb != null)
                        {
                            var storeItems = storeBL.GetStoreItems(consumerFb.ConsumerID);
                            if (storeItems != null)
                            {
                                storeInteractor.listGameStoreResponse = storeInteractor.createStoreItemsResponse(storeItems);

                                return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, storeInteractor));
                            }
                            else
                            {
                                response.HttpCode = 400;
                                response.Message  = "invalid parameters";
                                return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                            }
                        }
                        else
                        {
                            response.HttpCode = 404;
                            response.Message  = "Facebook information not found";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                        }
                    }
                    else
                    {
                        response.HttpCode     = 426;
                        response.InternalCode = versionRequired;
                        response.Message      = "Upgrade required";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, response));
                    }
                }
                else
                {
                    response.HttpCode = 404;
                    response.Message  = "Version or Platform parameter can not be null";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                }
            }
            catch (Exception)
            {
                response.HttpCode = 500;
                response.Message  = "something went wrong";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
            }
        }
示例#10
0
 public StoreController(ILogger <StoreController> logger, MyContext context)
 {
     _logger = logger;
     storeBL = new StoreBL(context);
 }
示例#11
0
 public void DeleteStore(long id)
 {
     StoreBL.DeleteStore(id);
 }
示例#12
0
 public void UpdateStore(Store store)
 {
     StoreBL.UpdateStore(store);
 }
示例#13
0
 public void AddStore(Store store)
 {
     StoreBL.AddStore(store);
 }
示例#14
0
 public Store GetStoreById(long id)
 {
     return(StoreBL.GetStoreById(id));
 }
示例#15
0
 public IEnumerable <Store> GetAllStores()
 {
     return(StoreBL.GetAllStores());
 }
示例#16
0
 public StoreController(AppDbContext db)
 {
     this.storeBL = new StoreBL(db);
     this.db      = db;
 }