Ejemplo n.º 1
0
        public async Task <T> AddAsync(T entity)
        {
            _dbContext.Set <T>().Add(entity);
            await _dbContext.SaveChangesAsync();

            return(entity);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Districts.Add(DistrictItem);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SecurityPerson = await _context.SecurityPersons.FindAsync(id);

            if (SecurityPerson != null)
            {
                _context.SecurityPersons.Remove(SecurityPerson);
                await _context.SaveChangesAsync();
            }

            return(Redirect(Url.GetLocalUrl(ReturnUrl)));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DistrictItem = await _context.Districts.FindAsync(id);

            if (DistrictItem != null)
            {
                _context.Districts.Remove(DistrictItem);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            NewsItem = await _context.Newses.FindAsync(id);

            if (NewsItem != null)
            {
                _context.Newses.Remove(NewsItem);
                await _context.SaveChangesAsync();
            }

            return(Redirect(Url.GetLocalUrl(ReturnUrl)));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                var townlist = (await _townService.GetAvailableTownsEagerAsync(HttpContext.User));
                if (townlist.Any())
                {
                    var groups = (await _groupService.ListGroupsForTownEagerAsync(HttpContext.User, townlist.First().Id));
                    ViewData["GroupList"] = new SelectList(groups, "Id", "Name");
                }

                return(Page());
            }

            _context.SecurityPersons.Add(SecurityPerson);
            await _context.SaveChangesAsync();

            return(Redirect(Url.GetLocalUrl(ReturnUrl)));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                var townlist = (await _townService.GetAvailableTownsEagerAsync(HttpContext.User));

                ViewData["TownList"] = new SelectList(townlist, "Id", "Name");
                if (townlist.Any())
                {
                    var groups = (await _groupService.ListGroupsForTownEagerAsync(HttpContext.User, townlist.First().Id));
                    ViewData["GroupList"] = new SelectList(groups, "Id", "Name");
                }


                return(Page());
            }


            var user = await _userManager.GetUserAsync(HttpContext.User);


            DriverItem.TownId = await _userManager.IsInRoleAsync(user, "TownManager") ? user.TownId : DriverItem.TownId;

            var driver = new DriverItem();
            await DriverItem.FillDriverItemAsync(driver);

            driver.CreateBy     = user.Id;
            driver.CreationDate = DateTime.Now;
            driver.Status       = StatusType.OK;
            driver.IdCardImage1 = DriverItem.PhotoIdCard1.UpdateUserFile(driver.IdCardImage1, _context, VisibilityType.CurrentDriver, "身份证国徽面图片", DriverItem.TownId, DriverItem.GroupId);
            driver.IdCardImage2 = DriverItem.PhotoIdCard2.UpdateUserFile(driver.IdCardImage2, _context, VisibilityType.CurrentDriver, "身份证相片面图片", DriverItem.TownId, DriverItem.GroupId);
            driver.LicenseImage = DriverItem.PhotoDriverLicense.UpdateUserFile(driver.LicenseImage, _context, VisibilityType.CurrentDriver, "驾驶证照片", DriverItem.TownId, DriverItem.GroupId);
            driver.AvatarImage  = DriverItem.PhotoAvatar.UpdateUserFile(driver.AvatarImage, _context, VisibilityType.CurrentDriver, "驾驶员图片", DriverItem.TownId, DriverItem.GroupId);
            driver.ExtraImage1  = DriverItem.ExtraImage1.UpdateUserFile(driver.ExtraImage1, _context, VisibilityType.CurrentDriver, "附加图片1", DriverItem.TownId, DriverItem.GroupId);
            driver.ExtraImage2  = DriverItem.ExtraImage2.UpdateUserFile(driver.ExtraImage2, _context, VisibilityType.CurrentDriver, "附加图片2", DriverItem.TownId, DriverItem.GroupId);
            driver.ExtraImage3  = DriverItem.ExtraImage3.UpdateUserFile(driver.ExtraImage3, _context, VisibilityType.CurrentDriver, "附加图片3", DriverItem.TownId, DriverItem.GroupId);

            _context.Drivers.Add(driver);
            await _context.SaveChangesAsync();

            return(Redirect(Url.GetLocalUrl(ReturnUrl)));
        }
Ejemplo n.º 8
0
        public static async Task SeedAsync(VehicleDbContext dbContext,
                                           ILoggerFactory loggerFactory, int?retry = 0)
        {
            // await dbContext.Database.EnsureCreatedAsync();

            if (await dbContext.Districts.AnyAsync())
            {
                return;
            }

            DistrictItem district = new DistrictItem()
            {
                Id = 1, Name = "甘井子区",
            };
            await dbContext.Districts.AddAsync(district);

            dbContext.Database.OpenConnection();
            try
            {
                //  dbContext.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Districts ON");
                await dbContext.SaveChangesAsync();

                //  dbContext.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Districts OFF");
            }
            finally
            {
                dbContext.Database.CloseConnection();
            }
            TownItem[] towns =
            {
                new TownItem()
                {
                    Id = 1, Name = "周水子街道", Address = "周水子街道", District = district, Code = 1,
                },
                new TownItem()
                {
                    Id = 2, Name = "椒金山街道", Address = "椒金山街道", District = district, Code = 2,
                },
                new TownItem()
                {
                    Id = 3, Name = "甘井子街道", Address = "甘井子街道", District = district, Code = 3,
                },
                new TownItem()
                {
                    Id = 4, Name = "南关岭街道", Address = "南关岭街道", District = district, Code = 4,
                },
                new TownItem()
                {
                    Id = 5, Name = "泡崖街道", Address = "泡崖街道", District = district, Code = 5,
                },
                new TownItem()
                {
                    Id = 6, Name = "中华路街道", Address = "中华路街道", District = district, Code = 6,
                },
                new TownItem()
                {
                    Id = 7, Name = "兴华街道", Address = "兴华街道", District = district, Code = 7,
                },
                new TownItem()
                {
                    Id = 8, Name = "机场街道", Address = "机场街道", District = district, Code = 8,
                },
                new TownItem()
                {
                    Id = 9, Name = "辛寨子街道", Address = "辛寨子街道", District = district, Code = 9,
                },
                new TownItem()
                {
                    Id = 10, Name = "红旗街道", Address = "红旗街道", District = district, Code = 10,
                },
                new TownItem()
                {
                    Id = 11, Name = "凌水街道", Address = "凌水街道", District = district, Code = 11,
                },
                new TownItem()
                {
                    Id = 12, Name = "大连湾街道", Address = "大连湾街道", District = district, Code = 12,
                },
                new TownItem()
                {
                    Id = 13, Name = "泉水街道", Address = "泉水街道", District = district, Code = 13,
                },
                new TownItem()
                {
                    Id = 14, Name = "革镇堡街道", Address = "革镇堡街道", District = district, Code = 14,
                },
                new TownItem()
                {
                    Id = 15, Name = "营城子街道", Address = "营城子街道", District = district, Code = 15,
                },
                new TownItem()
                {
                    Id = 16, Name = "七贤岭街道", Address = "七贤岭街道", District = district, Code = 16,
                },
                new TownItem()
                {
                    Id = 17, Name = "大连华侨果树农场", Address = "大连华侨果树农场", District = district, Code = 17,
                },
                new TownItem()
                {
                    Id = 18, Name = "其它街道", Address = "其它街道", District = district, Code = 18,
                },
            };
            await dbContext.Towns.AddRangeAsync(towns);

            dbContext.Database.OpenConnection();
            try
            {
                //  dbContext.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Towns ON");
                dbContext.SaveChanges();
                //  dbContext.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Towns OFF");
            }
            finally
            {
                dbContext.Database.CloseConnection();
            }


            GroupItem[] groups =
            {
                new GroupItem()
                {
                    Id = 1, Name = "周东社区", ChiefName = "张三", ChiefTel = "13555654554", TownId = towns[0].Id,
                },
                new GroupItem()
                {
                    Id = 2, Name = "周发社区", ChiefName = "李四", ChiefTel = "12444424555", TownId = towns[0].Id,
                },
                new GroupItem()
                {
                    Id = 3, Name = "周兴社区", ChiefName = "王五", ChiefTel = "1884424555", TownId = towns[0].Id,
                },
                new GroupItem()
                {
                    Id = 4, Name = "周西社区", ChiefName = "赵六", ChiefTel = "124342324555", TownId = towns[0].Id,
                },
                new GroupItem()
                {
                    Id = 5, Name = "周南社区", ChiefName = "冯七", ChiefTel = "1777724555", TownId = towns[0].Id,
                },
                new GroupItem()
                {
                    Id = 6, Name = "周盛社区", ChiefName = "刘八", ChiefTel = "12488884555", TownId = towns[0].Id,
                },
                new GroupItem()
                {
                    Id = 7, Name = "周顺社区", ChiefName = "唐九", ChiefTel = "12444989766", TownId = towns[0].Id,
                },
                new GroupItem()
                {
                    Id = 8, Name = "周水子社区", ChiefName = "滕十", ChiefTel = "12448889455", TownId = towns[0].Id,
                },
                new GroupItem()
                {
                    Id = 9, Name = "周北社区", ChiefName = "贾十一", ChiefTel = "124444774435", TownId = towns[0].Id,
                },
            };
            await dbContext.Groups.AddRangeAsync(groups);

            await dbContext.SaveChangesAsync();

            DriverItem[] drivers =
            {
                new DriverItem()
                {
                    Name = "容可佳", Gender = GenderType.Male, IdCardNumber = "111333122233445566", LicenseType = "A1", LicenseNumber = "5553445667", LicenseIssueDate = new DateTime(2003, 3, 3), LicenseValidYears = 10, Tel = "12244452677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "禄冰露", Gender = GenderType.Male, IdCardNumber = "222333122233445566", LicenseType = "A2", LicenseNumber = "6663445667", LicenseIssueDate = new DateTime(2004, 3, 3), LicenseValidYears = 10, Tel = "12344453677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "叶饮香", Gender = GenderType.Female, IdCardNumber = "333333122233445566", LicenseType = "A3", LicenseNumber = "7773445667", LicenseIssueDate = new DateTime(2005, 3, 3), LicenseValidYears = 10, Tel = "12444454677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "程欣悦", Gender = GenderType.Male, IdCardNumber = "444333122233445566", LicenseType = "B1", LicenseNumber = "8883445667", LicenseIssueDate = new DateTime(2006, 3, 3), LicenseValidYears = 10, Tel = "12564455677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "阚琼诗", Gender = GenderType.Male, IdCardNumber = "555333111233445566", LicenseType = "B2", LicenseNumber = "9991235667", LicenseIssueDate = new DateTime(2007, 3, 3), LicenseValidYears = 10, Tel = "12644456677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "耿许洌", Gender = GenderType.Female, IdCardNumber = "666333222233445566", LicenseType = "C3", LicenseNumber = "0002345667", LicenseIssueDate = new DateTime(2007, 1, 30), LicenseValidYears = 10, Tel = "12744456677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "富秋翠", Gender = GenderType.Male, IdCardNumber = "777333333233445566", LicenseType = "M", LicenseNumber = "2232345111", LicenseIssueDate = new DateTime(2008, 2, 22), LicenseValidYears = 10, Tel = "12814456677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "贺叶飞", Gender = GenderType.Male, IdCardNumber = "888333444233445566", LicenseType = "P", LicenseNumber = "2234565222", LicenseIssueDate = new DateTime(2009, 3, 1), LicenseValidYears = 10, Tel = "12392456677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "莘山芙", Gender = GenderType.Male, IdCardNumber = "222333555233445566", LicenseType = "C1", LicenseNumber = "2235675333", LicenseIssueDate = new DateTime(2000, 4, 2), LicenseValidYears = 10, Tel = "12303456677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "卓秀华", Gender = GenderType.Female, IdCardNumber = "222333666233445566", LicenseType = "C1", LicenseNumber = "2236785444", LicenseIssueDate = new DateTime(2003, 5, 3), LicenseValidYears = 10, Tel = "12344456677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "孟滇萍", Gender = GenderType.Male, IdCardNumber = "222333777233445566", LicenseType = "A1", LicenseNumber = "2237894555", LicenseIssueDate = new DateTime(2003, 6, 4), LicenseValidYears = 10, Tel = "12345456677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "尹从南", Gender = GenderType.Male, IdCardNumber = "222333888233445566", LicenseType = "A2", LicenseNumber = "2238905666", LicenseIssueDate = new DateTime(2003, 7, 5), LicenseValidYears = 10, Tel = "12346456677", TownId = 1
                },
                new DriverItem()
                {
                    Name = "菱芳蔼", Gender = GenderType.Male, IdCardNumber = "222333999233445566", LicenseType = "A3", LicenseNumber = "2233445777", LicenseIssueDate = new DateTime(2003, 8, 6), LicenseValidYears = 10, Tel = "12347456677", TownId = 1
                },
            };
            await dbContext.Drivers.AddRangeAsync(drivers);

            await dbContext.SaveChangesAsync();


            VehicleItem[] vehicles =
            {
                new VehicleItem()
                {
                    LicenceNumber = "辽BB1123", Brand = "本田", Name = "不知C4", Color = "黑", Type = VehicleType.HeavyAuto, LastRegisterDate = new DateTime(2015, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[0].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB1X23", Brand = "本田", Name = "高级C4", Color = "红", Type = VehicleType.HeavyLorry, LastRegisterDate = new DateTime(2016, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[1].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB2T23", Brand = "本田", Name = "不知C4", Color = "黄", Type = VehicleType.CommercialVehicle, LastRegisterDate = new DateTime(2017, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[2].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB8763", Brand = "本田", Name = "不知C4", Color = "蓝", Type = VehicleType.HeavyLorry, LastRegisterDate = new DateTime(2017, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[3].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BBAF23", Brand = "现代", Name = "不知C4", Color = "绿", Type = VehicleType.SmallBus, LastRegisterDate = new DateTime(2016, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[4].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB1444", Brand = "五菱", Name = "火舞C4", Color = "黑", Type = VehicleType.BigBus, LastRegisterDate = new DateTime(2017, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[0].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB17U3", Brand = "本田", Name = "不知C4", Color = "黑", Type = VehicleType.PrivateCar, LastRegisterDate = new DateTime(2016, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[1].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB1M88", Brand = "本田", Name = "不知C4", Color = "黑", Type = VehicleType.DangerLorry, LastRegisterDate = new DateTime(2014, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[2].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB1T99", Brand = "本田", Name = "火舞C4", Color = "黑", Type = VehicleType.HeavyLorry, LastRegisterDate = new DateTime(2017, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[3].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB1225", Brand = "本田", Name = "高级C4", Color = "黑", Type = VehicleType.HeavyAuto, LastRegisterDate = new DateTime(2016, 1, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[4].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB22B4", Brand = "五菱", Name = "火舞C4", Color = "蓝", Type = VehicleType.MiddleBus, LastRegisterDate = new DateTime(2017, 2, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[0].Id, DriverId = drivers[0].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB33N4", Brand = "五菱", Name = "不知C4", Color = "蓝", Type = VehicleType.DangerLorry, LastRegisterDate = new DateTime(2017, 3, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[1].Id, DriverId = drivers[0].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB4T44", Brand = "五菱", Name = "火舞C4", Color = "蓝", Type = VehicleType.MiddleBus, LastRegisterDate = new DateTime(2015, 4, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[1].Id, DriverId = drivers[0].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB5G44", Brand = "五菱", Name = "不知C4", Color = "黑", Type = VehicleType.BigBus, LastRegisterDate = new DateTime(2016, 5, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[1].Id, DriverId = drivers[0].Id
                },
                new VehicleItem()
                {
                    LicenceNumber = "辽BB1A44", Brand = "五菱", Name = "不知C4", Color = "黑", Type = VehicleType.SmallBus, LastRegisterDate = new DateTime(2017, 6, 1), ProductionDate = new DateTime(2001, 1, 1), GroupId = groups[1].Id, DriverId = drivers[0].Id
                },
            };

            await dbContext.Vehicles.AddRangeAsync(vehicles);

            await dbContext.SaveChangesAsync();


            NewsItem[] newses =
            {
                new NewsItem()
                {
                    Id = 1, Name = "你这有杂音我听不清楚", Content = "你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 2, Name = "我刚才刚买的车在那个", Content = "我刚才刚买的车在那个", Title = "我刚才刚买的车在那个", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 3, Name = "在道边上底下大梁磕道牙上了", Content = "在道边上底下大梁磕道牙上了", Title = "在道边上底下大梁磕道牙上了", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 4, Name = "您的车辆出险了现在要报案是吗", Content = "您的车辆出险了现在要报案是吗", Title = "您的车辆出险了现在要报案是吗", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 5, Name = "先生你好什么时间出的事情", Content = "先生你好什么时间出的事情", Title = "先生你好什么时间出的事情", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 6, Name = "刚刚时间刚刚出的", Content = "刚刚时间刚刚出的", Title = "刚刚时间刚刚出的", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 7, Name = "大概有几分钟啦就刚刚的事", Content = "大概有几分钟啦就刚刚的事", Title = "大概有几分钟啦就刚刚的事", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 8, Name = "半个小时是嘛就五十分钟", Content = "半个小时是嘛就五十分钟", Title = "半个小时是嘛就五十分钟", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 9, Name = "是在哪里出的事情是在大连嘛", Content = "是在哪里出的事情是在大连嘛", Title = "是在哪里出的事情是在大连嘛", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 10, Name = "是在辽宁省的大连市是吗?", Content = "是在辽宁省的大连市是吗?", Title = "是在辽宁省的大连市是吗?", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 11, Name = "在大连市的哪条路?甘井子革镇堡。", Content = "在大连市的哪条路?甘井子革镇堡。", Title = "在大连市的哪条路?甘井子革镇堡。", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 12, Name = "11你这有杂音我听不清楚", Content = "11你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.Notification
                },
                new NewsItem()
                {
                    Id = 13, Name = "22你这有杂音我听不清楚", Content = "22你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.AccidentCase
                },
                new NewsItem()
                {
                    Id = 14, Name = "33你这有杂音我听不清楚", Content = "33你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.AccidentCase
                },
                new NewsItem()
                {
                    Id = 15, Name = "44你这有杂音我听不清楚", Content = "44你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.AccidentCase
                },
                new NewsItem()
                {
                    Id = 16, Name = "55你这有杂音我听不清楚", Content = "55你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.AccidentCase
                },
                new NewsItem()
                {
                    Id = 17, Name = "66你这有杂音我听不清楚", Content = "66你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.LawAndRule
                },
                new NewsItem()
                {
                    Id = 18, Name = "77你这有杂音我听不清楚", Content = "77你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.LawAndRule
                },
                new NewsItem()
                {
                    Id = 19, Name = "88你这有杂音我听不清楚", Content = "77你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.LawAndRule
                },
                new NewsItem()
                {
                    Id = 20, Name = "99你这有杂音我听不清楚", Content = "77你这有杂音我听不清楚", Title = "你这有杂音我听不清楚", PublishDate = new DateTime(2018, 1, 1), Area = NewsAreaType.LawAndRule
                },
            };

            await dbContext.Newses.AddRangeAsync(newses);

            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                var townlist = (await _townService.GetAvailableTownsEagerAsync(HttpContext.User));

                ViewData["TownList"] = new SelectList(townlist, "Id", "Name");


                if (townlist.Any())
                {
                    var groups = (await _groupService.ListGroupsForTownEagerAsync(HttpContext.User, VehicleItem.TownId ?? -1));
                    ViewData["GroupList"] = new SelectList(groups, "Id", "Name");
                }

                return(Page());
            }

            var user = await _userManager.GetUserAsync(HttpContext.User);


            var vehicle = new VehicleItem()
            {
                Id               = VehicleItem.Id,
                Name             = VehicleItem.Name,
                Brand            = VehicleItem.Brand,
                Color            = VehicleItem.Color,
                Comment          = VehicleItem.Comment,
                AuditExpiredDate = VehicleItem.AuditExpiredDate,
                DumpDate         = VehicleItem.DumpDate,
                LicenceNumber    = VehicleItem.License,
                ProductionDate   = VehicleItem.ProductionDate,
                RealOwner        = VehicleItem.RealOwner,

                Type              = VehicleItem.Type,
                Usage             = VehicleItem.Usage,
                Agent             = VehicleItem.Agent,
                DriverId          = VehicleItem.DriverId,
                GpsEnabled        = VehicleItem.GpsEnabled,
                FirstRegisterDate = VehicleItem.RegisterDate,

                YearlyAuditDate = VehicleItem.YearlyAuditDate,
                VehicleStatus   = VehicleItem.VehicleStatus,

                GroupId = VehicleItem.GroupId,
                TownId  = VehicleItem.TownId,



                CreateBy     = user.Id,
                CreationDate = DateTime.Now,
                Status       = StatusType.OK,
            };


            vehicle.FrontImage   = VehicleItem.PhotoFront.UpdateUserFile(vehicle.FrontImage, _context, VisibilityType.CurrentVehicle, "车头部照片", VehicleItem.TownId, VehicleItem.GroupId);
            vehicle.RearImage    = VehicleItem.PhotoRear.UpdateUserFile(vehicle.RearImage, _context, VisibilityType.CurrentVehicle, "车尾部照片", VehicleItem.TownId, VehicleItem.GroupId);
            vehicle.GpsImage     = VehicleItem.PhotoGps.UpdateUserFile(vehicle.GpsImage, _context, VisibilityType.CurrentVehicle, "GPS照片", VehicleItem.TownId, VehicleItem.GroupId);
            vehicle.LicenseImage = VehicleItem.PhotoLicense.UpdateUserFile(vehicle.LicenseImage, _context, VisibilityType.CurrentVehicle, "行驶证照片", VehicleItem.TownId, VehicleItem.GroupId);
            vehicle.ExtraImage1  = VehicleItem.ExtraPhoto1.UpdateUserFile(vehicle.ExtraImage1, _context, VisibilityType.CurrentVehicle, "附加图片1", VehicleItem.TownId, VehicleItem.GroupId);
            vehicle.ExtraImage2  = VehicleItem.ExtraPhoto2.UpdateUserFile(vehicle.ExtraImage2, _context, VisibilityType.CurrentVehicle, "附加图片2", VehicleItem.TownId, VehicleItem.GroupId);
            vehicle.ExtraImage3  = VehicleItem.ExtraPhoto3.UpdateUserFile(vehicle.ExtraImage3, _context, VisibilityType.CurrentVehicle, "附加图片1", VehicleItem.TownId, VehicleItem.GroupId);
            _context.Vehicles.Add(vehicle);
            await _context.SaveChangesAsync();

            return(Redirect(Url.GetLocalUrl(ReturnUrl)));
        }