Esempio n. 1
0
        public IActionResult AddCargoType()
        {
            var model = new SettingInputModel {
                Action = nameof(this.AddCargoType)
            };

            return(this.View("AddSetting", model));
        }
Esempio n. 2
0
        public IActionResult AddLoadingBody()
        {
            var model = new SettingInputModel {
                Action = nameof(this.AddLoadingBody)
            };

            return(this.View("AddSetting", model));
        }
Esempio n. 3
0
        public async Task <IActionResult> AddCargoType(SettingInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.Json(new { isValid = false, html = this.View(input) }));
            }

            await this.settingsService.AddCargoTypeAsync(input);

            return(this.Json(new { isValid = true, redirectToUrl = this.Url.Action("CargoTypes", "Settings") }));
        }
Esempio n. 4
0
        public async Task AddLoadingBodyAsync(SettingInputModel input)
        {
            var body = new VehicleLoadingBody
            {
                Name = input.Name,
            };

            await this.loadBodies.AddAsync(body);

            await this.loadBodies.SaveChangesAsync();
        }
Esempio n. 5
0
        public async Task AddCargoTypeAsync(SettingInputModel input)
        {
            var type = new CargoType
            {
                Name = input.Name,
            };

            await this.cargoTypes.AddAsync(type);

            await this.cargoTypes.SaveChangesAsync();
        }
Esempio n. 6
0
        public async Task AddPersonRoleAsync(SettingInputModel input)
        {
            var role = new PersonRole
            {
                Name = input.Name,
            };

            await this.perRoles.AddAsync(role);

            await this.perRoles.SaveChangesAsync();
        }
Esempio n. 7
0
        public async void AddLoadingBodyTest()
        {
            using var dbContext = this.GetDbContext();
            var service = this.GetSettingsService(dbContext);
            var body    = new SettingInputModel {
                Name = "test"
            };
            await service.AddLoadingBodyAsync(body);

            Assert.True(dbContext.VehicleLoadingBodies.Any(r => r.Name == body.Name));
            Assert.Equal(2, dbContext.VehicleLoadingBodies.Count());
        }
Esempio n. 8
0
        public async void AddCargoTypeTest()
        {
            using var dbContext = this.GetDbContext();
            var role = new SettingInputModel {
                Name = "test1"
            };
            var service = this.GetSettingsService(dbContext);
            await service.AddCargoTypeAsync(role);

            Assert.True(dbContext.CargoTypes.Any(r => r.Name == role.Name));
            Assert.Equal(2, dbContext.CargoTypes.Count());
        }
        public async Task <ResultModel <SettingOutputModel> > UpdateSetting([FromBody] SettingInputModel item)
        {
            var settingItem = new SettingModel()
            {
                Id                = item.Id,
                Name              = item.Name,
                IntValue          = item.IntValue,
                StringValue       = item.StringValue,
                TimeValue         = item.TimeValue,
                SettingValueId    = item.SettingValueId,
                DoubleValue       = item.DoubleValue,
                SettingDataTypeId = item.SettingDataTypeId
            };

            return(await _settingStoreService.UpdateAndSaveAsync <SettingOutputModel>(settingItem));
        }