Exemple #1
0
        public static void CreateRegistration(Registration reg, string account)
        {
            using (var site = new SCBWIContext()) {
                var user = (from u in site.Users
                            where u.Account == account
                            select u).First();

                user.Registration = reg;

                site.Entry(user).State = EntityState.Modified;
                site.SaveChanges();
            }
        }
Exemple #2
0
        public static void CompleteWizard()
        {
            using (var site = new SCBWIContext()) {
                var status = (from c in site.Information
                              where c.Category == Category.Ready
                              select c).SingleOrDefault();

                status.Value = "ready";

                site.Entry(status).State = EntityState.Modified;

                site.SaveChanges();
            }
        }
Exemple #3
0
        public static string CalcTotalByAccount(string account)
        {
            var site = new SCBWIContext();

            var user = (from u in site.Users
                        where u.Account == account
                        select u).SingleOrDefault();

            user.Registration = site.Registrations.Find(user.RegistrationID);

            double total = 0;

            var regtype = (from r in site.Prices
                           where r.Name == user.Registration.Type
                           select r).SingleOrDefault();

            total += regtype.Value;

            if (user.Registration.Intensive != null)
            {
                var intensive = (from i in site.Prices
                                 where i.Name == user.Registration.Intensive
                                 select i).SingleOrDefault();

                total += intensive.Value;
            }

            if (user.Critiques != null || user.Critiques.Count() > 0)
            {
                var critiques = (from p in site.Prices
                                 where p.Category == Category.Critique
                                 select p).FirstOrDefault();

                total += (critiques.Value * user.Critiques.Count());
            }

            user.Total = total;

            site.Entry(user).State = EntityState.Modified;
            site.SaveChanges();

            return(total.ToString());
        }