Example #1
0
        private void SaveService()
        {
            List <ModelService> services = new List <ModelService>();
            ModelService        service  = new ModelService()
            {
                ItemName   = TxtName.Text,
                costprice  = Convert.ToDouble(dpCostPrice.Value),
                Crate      = Convert.ToDouble(DpCrate.Value),
                Discount   = Convert.ToDouble(DpDiscount.Value),
                IsActive   = ISActive.Checked,
                IsDisc     = IsDis.Checked,
                IsImp      = IsImp.Checked,
                IsRaw      = Isrw.Checked,
                Location   = TxtLocation.Text,
                munit      = MU.Text,
                ReorderLvl = (int)dpReorder.Value,
                sellprice  = (double)DpCellPrice.Value,
                ItemCode   = TxtCode.Text,
            };

            services.Add(service);
            ServiceController saver = new ServiceController();

            foreach (ModelService item in services)
            {
                if (!saver.AddService(item.ItemName, item.ItemCode, item.costprice, item.Crate, item.Discount, item.IsActive, item.IsDisc, item.IsImp, item.IsRaw, item.Location, item.munit, item.ReorderLvl, item.sellprice))
                {
                    MetroMessageBox.Show(this, "Service not saved ", "");
                }
                else
                {
                    MetroMessageBox.Show(this, "Service saved ", "");
                }
            }
        }
Example #2
0
        public async Task PostService_ShouldFail_WhenSameName()
        {
            var controller = new ServiceController(_service);
            var serviceDto = GetServiceDto();
            var result     = await controller.AddService(serviceDto);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(ConflictObjectResult));
        }
Example #3
0
        public async Task PostService_ShouldReturnvalidService()
        {
            var controller = new ServiceController(_service);
            var serviceDto = GetServiceDto();
            var result     = await controller.AddService(serviceDto) as CreatedAtActionResult;

            var service = result.Value as ServiceResponse;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(service.Id, "".GetType());
            Assert.AreEqual(result.StatusCode, 201);
        }
Example #4
0
        public async Task PostService_ShouldReturnServiceWithName()
        {
            var controller = new ServiceController(_service);
            // Add a new service with a different name
            var serviceDto = GetServiceDto();

            serviceDto.Name = "Another Service";
            await controller.AddService(serviceDto);

            // get all services with matching names
            var partialName = "Sample";
            var services    = await controller.GetAll(partialName);

            Assert.IsNotNull(services);
            Assert.IsTrue(services.Count == 1);
            Assert.AreEqual("Sample service", services[0].Name);
        }
Example #5
0
 public void RegisterButton(string permissionName, Texture2D texture, Action buttonClickedAction, Action <bool> groupUpdated, Func <string> tooltip)
 {
     if (!Main.dedServ)
     {
         GenericExtensionService genericService = new GenericExtensionService(instance.extensionMenuService, texture, permissionName, buttonClickedAction, groupUpdated, tooltip);
         ServiceController.AddService(genericService);
         instance.extensionMenuService.AddGeneric(genericService);
         //modExtensions.AddButton(texture, buttonClickedAction, groupUpdated, tooltip);
     }
 }