Beispiel #1
0
        public ResponseModel <Delivery> UpdateDelivery(Delivery objDeliveryDetails)
        {
            try
            {
                DeliveryProvider objDeliveryProvider = new DeliveryProvider(_context);
                Delivery         updatedDelivery     = objDeliveryProvider.UpdateDelivery(objDeliveryDetails);

                ResponseModel <Delivery> objResponseModel = new ResponseModel <Delivery>
                {
                    StatusCode     = 1,
                    Message        = "Successfully Updated",
                    ResponseObject = updatedDelivery
                };
                return(objResponseModel);
            }
            catch (Exception ex)
            {
                ResponseModel <Delivery> objResponseModel = new ResponseModel <Delivery>
                {
                    StatusCode = 0,
                    Message    = ex.Message,
                };
                return(objResponseModel);
            }
        }
        public void Delete_DeliveryExists_ReturnTrue()
        {
            // Arrange
            DeliveryProvider deliveryProvider = new DeliveryProvider();
            var             allDeliverys      = deliveryProvider.GetAll().OrderByDescending(p => p.Id);
            Delivery        lastDelivery      = allDeliverys.FirstOrDefault() ?? new Delivery();
            DeliveryHandler deliveryHandler   = new DeliveryHandler();

            // Act
            bool result          = deliveryHandler.Delete(lastDelivery.Id);
            var  deletedDelivery = deliveryProvider.GetById(lastDelivery.Id);

            // Assert
            Assert.IsTrue(result);
            Assert.IsNull(deletedDelivery);
        }
        public void Add_DeliveryCorrectEntity_ReturnId()
        {
            // Arrange
            DeliveryProvider deliveryProvider = new DeliveryProvider();
            var      allDeliverys             = deliveryProvider.GetAll().OrderByDescending(p => p.Id);
            Delivery lastDelivery             = allDeliverys.FirstOrDefault() ?? new Delivery();

            DeliveryHandler deliveryHandler = new DeliveryHandler();
            Delivery        delivery        = new Delivery();

            delivery.Name  = "Name";
            delivery.Price = 123.45m;
            // Act
            int id = deliveryHandler.Add(delivery);

            // Assert
            Assert.IsTrue(lastDelivery.Id < id);
        }
        public void Update_DeliveryCorrectEntity_ReturnTrueAndNewEntityHasCorrectSetFields()
        {
            // Arrange
            DeliveryProvider deliveryProvider = new DeliveryProvider();
            var oldDeliverys = deliveryProvider.GetById(1);

            DeliveryHandler deliveryHandler = new DeliveryHandler();
            Delivery        delivery        = new Delivery();

            delivery.Id    = 1;
            delivery.Name  = "NEW_Name";
            delivery.Price = 999.99m;
            // Act
            bool result       = deliveryHandler.Update(delivery);
            var  newDeliverys = deliveryProvider.GetById(1);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual("NEW_Name", newDeliverys.Name);
            Assert.AreEqual(999.99m, newDeliverys.Price);
        }
Beispiel #5
0
        public ResponseModel ApprovalRequest(ApprovalRequest objApprovalRequest)
        {
            try
            {
                switch (objApprovalRequest.Type)
                {
                case 0:
                    ScenarioProvider objScenarioProvider = new ScenarioProvider(_context);
                    objScenarioProvider.ApproveScenario(objApprovalRequest);
                    break;

                case 1:
                    ScriptProvider objScriptProvider = new ScriptProvider(_context);
                    objScriptProvider.ApproveScript(objApprovalRequest);
                    break;

                case 2:
                    DeliveryProvider objDeliveryProvider = new DeliveryProvider(_context);
                    objDeliveryProvider.ApproveDelivery(objApprovalRequest);
                    break;
                }
                ResponseModel objResponseModel = new ResponseModel
                {
                    StatusCode = 1,
                    Message    = "Action Performed Successfully"
                };
                return(objResponseModel);
            }
            catch (Exception ex)
            {
                ResponseModel objResponseModel = new ResponseModel
                {
                    StatusCode = 0,
                    Message    = ex.Message
                };
                return(objResponseModel);
            }
        }
Beispiel #6
0
        public ResponseModel DeleteDelivery(Delivery objDeliveryDetails)
        {
            try
            {
                DeliveryProvider objDeliveryProvider = new DeliveryProvider(_context);
                objDeliveryProvider.DeleteDelivery(objDeliveryDetails);

                ResponseModel objResponseModel = new ResponseModel
                {
                    Message    = "Successfully Deleted",
                    StatusCode = 1
                };
                return(objResponseModel);
            }
            catch (Exception ex)
            {
                ResponseModel objResponseModel = new ResponseModel
                {
                    Message    = ex.Message,
                    StatusCode = 1
                };
                return(objResponseModel);
            }
        }
Beispiel #7
0
 public ResponseModel <Delivery> GetDelivery(GetById objGetById)
 {
     try
     {
         DeliveryProvider         objDeliveryProvider = new DeliveryProvider(_context);
         Delivery                 objDelivery         = objDeliveryProvider.GetDeliveryById(objGetById.Id);
         ResponseModel <Delivery> objResponseModel    = new ResponseModel <Delivery>
         {
             StatusCode     = 0,
             Message        = "Successful",
             ResponseObject = objDelivery
         };
         return(objResponseModel);
     }
     catch (Exception ex)
     {
         ResponseModel <Delivery> objResponseModel = new ResponseModel <Delivery>
         {
             StatusCode = 0,
             Message    = ex.Message
         };
         return(objResponseModel);
     }
 }
        public void TestFillTestData()
        {
            var deliveryProvider1 = new DeliveryProvider()
            {
                Name = "Test Provider 1", WebSite = "www.test1.cz"
            };

            _deliveryAreaRepository.SaveDeliveryProvider(deliveryProvider1).GetAwaiter().GetResult();
            var deliveryProvider2 = new DeliveryProvider()
            {
                Name = "Test Provider 2", WebSite = "www.test2.cz"
            };

            _deliveryAreaRepository.SaveDeliveryProvider(deliveryProvider2).GetAwaiter().GetResult();


            IndexKeysDefinition <DeliveryArea> keyLocationY = "{ Polygon: '2dsphere' }";
            var locationIndexModelY = new CreateIndexModel <DeliveryArea>(keyLocationY);

            GeoJson2DGeographicCoordinates oneY   = new GeoJson2DGeographicCoordinates(50.094166, 14.439476);
            GeoJson2DGeographicCoordinates twoY   = new GeoJson2DGeographicCoordinates(50.093726, 14.407547);
            GeoJson2DGeographicCoordinates threeY = new GeoJson2DGeographicCoordinates(50.10716, 14.400681);
            GeoJson2DGeographicCoordinates fourY  = new GeoJson2DGeographicCoordinates(50.112224, 14.431237);
            GeoJson2DGeographicCoordinates fiveY  = new GeoJson2DGeographicCoordinates(50.105178, 14.44497);
            GeoJson2DGeographicCoordinates sixY   = new GeoJson2DGeographicCoordinates(50.094166, 14.439476);

            GeoJson2DGeographicCoordinates[] coord_arrayY = new GeoJson2DGeographicCoordinates[]
            { oneY, twoY, threeY, fourY, fiveY, sixY };


            _deliveryAreaRepository.SaveDeliveryArea(new DeliveryArea()
            {
                PolygonName        = "Praha Within 2",
                Polygon            = GeoJson.Polygon(coord_arrayY),
                DeliveryProviderId = deliveryProvider1.Id
            }).GetAwaiter().GetResult();


            IndexKeysDefinition <DeliveryArea> keyLocation = "{ Polygon: '2dsphere' }";
            var locationIndexModel = new CreateIndexModel <DeliveryArea>(keyLocation);

            GeoJson2DGeographicCoordinates one   = new GeoJson2DGeographicCoordinates(50.049057, 14.42282);
            GeoJson2DGeographicCoordinates two   = new GeoJson2DGeographicCoordinates(50.067793, 14.500068);
            GeoJson2DGeographicCoordinates three = new GeoJson2DGeographicCoordinates(50.128797, 14.442733);
            GeoJson2DGeographicCoordinates four  = new GeoJson2DGeographicCoordinates(50.10392, 14.385741);
            GeoJson2DGeographicCoordinates five  = new GeoJson2DGeographicCoordinates(50.086741, 14.413894);
            GeoJson2DGeographicCoordinates six   = new GeoJson2DGeographicCoordinates(50.049057, 14.42282);

            GeoJson2DGeographicCoordinates[] coord_array = new GeoJson2DGeographicCoordinates[]
            { one, two, three, four, five, six };


            _deliveryAreaRepository.SaveDeliveryArea(new DeliveryArea()
            {
                PolygonName        = "Praha Within 1",
                Polygon            = GeoJson.Polygon(coord_array),
                DeliveryProviderId = deliveryProvider2.Id
            }).GetAwaiter().GetResult();

            IndexKeysDefinition <DeliveryArea> keyLocation1 = "{ Polygon: '2dsphere' }";
            var locationIndexModel1 = new CreateIndexModel <DeliveryArea>(keyLocation);

            GeoJson2DGeographicCoordinates xone   = new GeoJson2DGeographicCoordinates(50.102976, 14.383515);
            GeoJson2DGeographicCoordinates xtwo   = new GeoJson2DGeographicCoordinates(50.07478, 14.427804);
            GeoJson2DGeographicCoordinates xthree = new GeoJson2DGeographicCoordinates(50.043482, 14.425744);
            GeoJson2DGeographicCoordinates xfour  = new GeoJson2DGeographicCoordinates(50.039293, 14.379738);
            GeoJson2DGeographicCoordinates xfive  = new GeoJson2DGeographicCoordinates(50.070594, 14.342659);
            GeoJson2DGeographicCoordinates xsix   = new GeoJson2DGeographicCoordinates(50.102976, 14.383515);

            GeoJson2DGeographicCoordinates[] xcoord_array = new GeoJson2DGeographicCoordinates[]
            { xone, xtwo, xthree, xfour, xfive, xsix };


            _deliveryAreaRepository.SaveDeliveryArea(new DeliveryArea()
            {
                PolygonName        = "Praha Outside 1",
                Polygon            = GeoJson.Polygon(xcoord_array),
                DeliveryProviderId = deliveryProvider1.Id
            }).GetAwaiter().GetResult();
        }
Beispiel #9
0
 public async Task SaveDeliveryProvider(DeliveryProvider deliveryProvider)
 {
     await _deliveryProviderCollection.InsertOneAsync(deliveryProvider);
 }
Beispiel #10
0
 public void PublishToSubscriber(Message pMessage)
 {
     DeliveryProvider.SubmitDelivery(pMessage);
 }