コード例 #1
0
        public IActionResult Edit(Stolon applicationConfig)
        {
            if (ModelState.IsValid)
            {
                //Configurations.Application = applicationConfig;
                _context.Update(applicationConfig);
                _context.SaveChanges();

                return RedirectToAction("Index");
            }
            return View(applicationConfig);
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: ChavFDG/Stolons
 private async Task CreateTestAcount(ApplicationDbContext context, UserManager<ApplicationUser> userManager,Stolon stolon)
 {
     await CreateAcount(context,
             userManager,
             "Maurice",
             "Robert",
             "*****@*****.**",
             "*****@*****.**",
             Configurations.Role.User,
             Configurations.UserType.Producer,
             stolon);
 }
コード例 #3
0
ファイル: Startup.cs プロジェクト: ChavFDG/Stolons
        private async Task CreateAcount(ApplicationDbContext context, UserManager<ApplicationUser> userManager, string name, string surname, string email, string password, Configurations.Role role, Configurations.UserType userType, Stolon stolon, string postCode = "07000")
        {

            if (context.Consumers.Any(x => x.Email == email) || context.Producers.Any(x => x.Email == email))
                return;
            StolonsUser user;
            switch (userType)
            {
                case Configurations.UserType.Producer:
                    user = new Producer();
                    break;
                case Configurations.UserType.Consumer:
                    user = new Consumer();
                    break;
                default:
                    user = new Consumer();
                    break;
            }
            user.Name = name;
            user.Surname = surname;
            user.Email = email;
            user.Avatar = Path.Combine(Configurations.UserAvatarStockagePath, Configurations.DefaultFileName);
            user.RegistrationDate = DateTime.Now;
            user.Enable = true;
            user.PostCode = postCode;
            user.Stolon = stolon;

            switch (userType)
            {
                case Configurations.UserType.Producer:
                    Producer producer = user as Producer;
                    producer.CompanyName = "La ferme de " + producer.Name;
                    producer.Latitude = 44.7354673;
                    producer.Longitude = 4.601407399999971;
                    context.Producers.Add(producer);
                    break;
                case Configurations.UserType.Consumer:
                    context.Consumers.Add(user as Consumer);
                    break;
                default:
                    context.Consumers.Add(user as Consumer);
                    break;
            }


            #region Creating linked application data
            var appUser = new ApplicationUser { UserName = user.Email, Email = user.Email };
            appUser.User = user;

            var result = await userManager.CreateAsync(appUser, password);
            if (result.Succeeded)
            {
                //Add user role
                result = await userManager.AddToRoleAsync(appUser, role.ToString());
                //Add user type
                result = await userManager.AddToRoleAsync(appUser, userType.ToString());
            }
            #endregion Creating linked application data

            context.SaveChanges();

        }
コード例 #4
0
ファイル: Startup.cs プロジェクト: ChavFDG/Stolons
 private async Task CreateAdminAccount(ApplicationDbContext context, UserManager<ApplicationUser> userManager, Stolon stolon)
 {
     await CreateAcount(context,
             userManager,
             "PARAVEL",
             "Damien",
             "*****@*****.**",
             "*****@*****.**",
             Configurations.Role.Administrator,
             Configurations.UserType.Consumer,
             stolon);
     await CreateAcount(context,
             userManager,
             "MICHON",
             "Nicolas",
             "*****@*****.**",
             "*****@*****.**",
             Configurations.Role.Administrator,
             Configurations.UserType.Consumer,
             stolon);
     await CreateAcount(context,
             userManager,
             "Maurice",
             "Robert",
             "*****@*****.**",
             "*****@*****.**",
             Configurations.Role.User,
             Configurations.UserType.Producer,
             stolon);
 }
コード例 #5
0
ファイル: Startup.cs プロジェクト: ChavFDG/Stolons
        private List<Stolon> CreateStolons(ApplicationDbContext context)
        {
            List<Stolon> stolons = new List<Stolon>();
            Stolon stolon = new Stolon();
            stolon.IsInMaintenance = false;
            stolon.IsModeSimulated = false;

            stolon.Label = "Stolons de Privas";
            stolon.AboutPageText = "Les Stolons de Privas est une association loi 1901";
            stolon.Address = "07000 PRIVAS";
            stolon.PhoneNumber = "06 64 86 66 93";
            stolon.ContactMailAddress = "*****@*****.**";

            stolon.DeliveryAndStockUpdateDayStartDate = DayOfWeek.Wednesday;
            stolon.DeliveryAndStockUpdateDayStartDateHourStartDate = 12;
            stolon.DeliveryAndStockUpdateDayStartDateMinuteStartDate = 00;
            stolon.OrderDayStartDate = DayOfWeek.Sunday;
            stolon.OrderHourStartDate = 16;
            stolon.OrderMinuteStartDate = 00;

            stolon.UseSubscipstion = true;
            stolon.SubscriptionStartMonth = Stolon.Month.September;

            stolon.OrderDeliveryMessage = "Votre panier est disponible jeudi de 17h30 à 19h au : 10 place de l'hotel de ville, 07000 Privas";

            stolon.UseProducersFee = true;
            stolon.ProducersFee = 5;

            stolon.UseSympathizer = true;
            stolon.SympathizerSubscription = 2;
            stolon.ConsumerSubscription = 10;
            stolon.ProducerSubscription = 20;

            context.Add(stolon);
            context.SaveChanges();

            stolons.Add(stolon);
            return stolons;
        }
コード例 #6
0
ファイル: Startup.cs プロジェクト: ChavFDG/Stolons
 private async Task InitializeSampleAndTestData(IServiceProvider serviceProvider, ApplicationDbContext context, UserManager<ApplicationUser> userManager,Stolon stolon)
 {
     await CreateTestAcount(context, userManager,stolon);
     CreateProductsSamples(context);
 }
コード例 #7
0
 public AdherentStolon(Adherent adherent, Stolon stolon, bool isActiveStolon = false)
 {
     Adherent       = adherent;
     Stolon         = stolon;
     IsActiveStolon = isActiveStolon;
 }
コード例 #8
0
 public List <Sympathizer> GetSympathizers(Stolon stolon)
 {
     return(this.Sympathizers.Include(x => x.Stolon).Where(x => x.StolonId == stolon.Id).ToList());
 }