Пример #1
0
 protected override void Seed(MagazineContext context)
 {
     context.Customers.Add(new Customer()
     {
         CustomerName = "Test Customer"
     });
 }
Пример #2
0
        public static void RegistrationMenu()
        {
            Console.WriteLine("===========\n" +
                              "РЕГИСТРАЦИЯ\n" +
                              "===========");

            Person newPerson = new Person()
            {
                Name        = SetInformation.SetName(),
                Surname     = SetInformation.SetSurname(),
                Address     = SetInformation.SetAddress(),
                PhoneNumber = SetInformation.SetPhoneNumber()
            };

            User newUser = new User()
            {
                Login    = SetInformation.SetLogin(),
                Password = SetInformation.SetPassword(),
                Person   = newPerson
            };

            using (var context = new MagazineContext())
            {
                if (!context.People.Contains(newPerson))
                {
                    if (!context.Users.Contains(newUser))
                    {
                        context.Users.Add(newUser);
                        context.SaveChanges();

                        Console.WriteLine("Зарегистрированно");
                    }
                }
            }
        }
Пример #3
0
        public static void CreateMagazineShipping(UsersSubscription usersSubscription)
        {
            using (var context = new MagazineContext())
            {
                List <MagazineShipping> magazines = new List <MagazineShipping>();

                foreach (Magazine magazine in context.Magazines.ToList())
                {
                    MagazineShipping newMagazineShipping = new MagazineShipping()
                    {
                        UsersSubscription = usersSubscription,
                        Magazine          = magazine,
                        DeliverTime       = DateTime.Now,
                        IsDelivered       = true
                    };
                    magazines.Add(newMagazineShipping);
                }

                do
                {
                    Console.WriteLine("Если вы получили все журналы нажмите на 1");

                    string delivered = Console.ReadLine().Trim();

                    if (delivered == "1")
                    {
                        context.MagazineShippings.AddRange(magazines);
                        context.SaveChanges();
                        break;
                    }
                } while (true);
            }
        }
Пример #4
0
        public TeacherController(MagazineContext magazineContext, IRepositoryFacade repositoryFacade)
        {
            this.repositoryFacade = repositoryFacade;
            this.magazineContext  = magazineContext;

            TeacherSubjectMappingModelRepository = this.repositoryFacade.CreateGenericRepository <TeacherSubjectMappingModel>();
            GroupTeacherMappingModelRepository   = this.repositoryFacade.CreateGenericRepository <GroupTeacherMappingModel>();
        }
Пример #5
0
        public static void MakeSubsRepors()
        {
            string month = ((Month)DateTime.Now.Month).ToString();

            using (FileStream fileStream = new FileStream("earningsReport.csv", FileMode.OpenOrCreate))
                using (StreamWriter streamWriter = new StreamWriter(fileStream))
                    using (var context = new MagazineContext())
                    {
                        int subsCount = context.UsersSubscriptions.Where(userSub => userSub.Subscription.SubscriptionsTimeInMonth == DateTime.Now.Month).ToList().Count;
                        streamWriter.WriteLine("Month;SubsCount");
                        streamWriter.WriteLine($"{month};{subsCount}");
                    }
        }
Пример #6
0
 public MagazineController(IRepositoryFacade repositoryFacade, IHttpContextAccessor httpContextAccessor, MagazineContext magazineContext)
 {
     this.repositoryFacade   = repositoryFacade;
     magazineRepository      = this.repositoryFacade.CreateEagerGenericRepository <Magazine>();
     magazineRepositoryEager = this.repositoryFacade.CreateEagerGenericRepository <Magazine>() as IEagerGenericRepository <Magazine>;
     subjectRepository       = this.repositoryFacade.CreateGenericRepository <Subject>();
     groupRepository         = this.repositoryFacade.CreateEagerGenericRepository <Group>() as IEagerGenericRepository <Group>;
     recordsRepository       = this.repositoryFacade.CreateGenericRepository <Record>();
     this.userId             = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
     this.magazineContext    = magazineContext;
     commentRepository       = this.repositoryFacade.CreateGenericRepository <Comment>();
     studentRepository       = this.repositoryFacade.CreateGenericRepository <Student>();
 }
Пример #7
0
        public static void MakeEarningsRepors()
        {
            string month = ((Month)DateTime.Now.Month).ToString();

            using (FileStream fileStream = new FileStream("earningsReport.csv", FileMode.OpenOrCreate))
                using (StreamWriter streamWriter = new StreamWriter(fileStream))
                    using (var context = new MagazineContext())
                    {
                        double earning = context.UsersSubscriptions.Where(userSub => userSub.Subscription.SubscriptionsTimeInMonth == DateTime.Now.Month).ToList().Sum(sum => sum.Subscription.Price);
                        streamWriter.WriteLine("Month;Earning");
                        streamWriter.WriteLine($"{month};{earning}");
                    }
        }
        public static void DeleteSubsription(User user)
        {
            using (var context = new MagazineContext())
            {
                var userSub = context.UsersSubscriptions.Where(userSubscription => userSubscription.User.Id == user.Id).SingleOrDefault();
                if (userSub != null)
                {
                    context.UsersSubscriptions.Remove(userSub);
                    context.SaveChanges();
                    return;
                }

                throw new ArgumentNullException("Нет такого пользователя с такой подпиской");
            }
        }
Пример #9
0
        public static void CreateMagazine()
        {
            Magazine newMagazine = new Magazine()
            {
                Name        = SetInformation.SetName(),
                Theme       = SetInformation.SetTheme(),
                DateOfIssue = DateTime.Now
            };

            using (var context = new MagazineContext())
            {
                context.Magazines.Add(newMagazine);
                context.SaveChanges();
            }
        }
        public static UsersSubscription AddSubsription(User user, SubsritionsType subsritionsType)
        {
            using (var context = new MagazineContext())
            {
                UsersSubscription newUsersSubscription = new UsersSubscription()
                {
                    Subscription = context.Subscriptions.Where(sub => sub.SubscriptionsTimeInMonth == (int)subsritionsType).SingleOrDefault(),
                    User         = context.Users.Where(searchUser => searchUser.Id == user.Id).SingleOrDefault()
                };

                context.UsersSubscriptions.Add(newUsersSubscription);
                context.SaveChanges();

                return(newUsersSubscription);
            }
        }
Пример #11
0
 public AttestationController(IHttpContextAccessor httpContextAccessor, IRepositoryFacade repositoryFacade, MagazineContext magazineContext)
 {
     this.userId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
     this.attestationRepository  = repositoryFacade.CreateGenericRepository <Attestation>();
     eagerGroupRepository        = repositoryFacade.CreateEagerGenericRepository <Group>() as IEagerGenericRepository <Group>;
     eagerAttestationRepository  = repositoryFacade.CreateEagerGenericRepository <Attestation>() as IEagerGenericRepository <Attestation>;
     groupRepository             = repositoryFacade.CreateGenericRepository <Group>();
     markRepository              = repositoryFacade.CreateGenericRepository <Mark>();
     subjectRepository           = repositoryFacade.CreateGenericRepository <Subject>();
     groupSubjetcRepository      = repositoryFacade.CreateEagerGenericRepository <GroupSubjectMappingModel>() as IEagerGenericRepository <GroupSubjectMappingModel>;
     groupTeacherRepository      = repositoryFacade.CreateGenericRepository <GroupTeacherMappingModel>();
     studentRepository           = repositoryFacade.CreateGenericRepository <Student>();
     attestationRecordRepository = repositoryFacade.CreateGenericRepository <AttestationRecord>();
     eagerMarkRepository         = repositoryFacade.CreateEagerGenericRepository <Mark>() as IEagerGenericRepository <Mark>;
     this.magazineContext        = magazineContext;
 }
Пример #12
0
        public static User Entry()
        {
            Console.WriteLine("====" +
                              "ВХОД\n" +
                              "====");
            Console.WriteLine("Введите логин:");
            string login = SetInformation.SetLogin();

            Console.WriteLine("Введите пароль:");
            string password = SetInformation.SetLogin();

            using (var context = new MagazineContext())
            {
                return(context.Users.Where(user => user.Login == login && user.Password == password).SingleOrDefault());
            }
        }
Пример #13
0
 public BooksAndAuthorRepository(MagazineContext context) : base(context)
 {
     _context  = context;
     _entities = context.Set <BooksAndAuthor>();
 }
Пример #14
0
 public AuthorRepository(MagazineContext context) : base(context)
 {
 }
Пример #15
0
 public EFGenericRepository(MagazineContext context)
 {
     _context = context;
     _dbSet   = context.Set <TEntity>();
 }
Пример #16
0
 public UnitOfWork(MagazineContext context)
 {
     _context = context;
 }
Пример #17
0
 public BookRepository(MagazineContext context) : base(context)
 {
     _entities = context.Set <Book>();
 }
Пример #18
0
 public Repository(MagazineContext context)
 {
     _context  = context;
     _entities = context.Set <T>();
 }
Пример #19
0
 public HomeController(ILogger <HomeController> logger, MagazineContext context)
 {
     this.context = context;
     _logger      = logger;
 }
Пример #20
0
 public OrderRepository(MagazineContext context) : base(context)
 {
     _entities = context.Set <Order>();
 }
Пример #21
0
 public MagazinesController(MagazineContext context)
 {
     _context = context;
 }