protected override void Seed(MagazineContext context) { context.Customers.Add(new Customer() { CustomerName = "Test Customer" }); }
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("Зарегистрированно"); } } } }
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); } }
public TeacherController(MagazineContext magazineContext, IRepositoryFacade repositoryFacade) { this.repositoryFacade = repositoryFacade; this.magazineContext = magazineContext; TeacherSubjectMappingModelRepository = this.repositoryFacade.CreateGenericRepository <TeacherSubjectMappingModel>(); GroupTeacherMappingModelRepository = this.repositoryFacade.CreateGenericRepository <GroupTeacherMappingModel>(); }
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}"); } }
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>(); }
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("Нет такого пользователя с такой подпиской"); } }
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); } }
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; }
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()); } }
public BooksAndAuthorRepository(MagazineContext context) : base(context) { _context = context; _entities = context.Set <BooksAndAuthor>(); }
public AuthorRepository(MagazineContext context) : base(context) { }
public EFGenericRepository(MagazineContext context) { _context = context; _dbSet = context.Set <TEntity>(); }
public UnitOfWork(MagazineContext context) { _context = context; }
public BookRepository(MagazineContext context) : base(context) { _entities = context.Set <Book>(); }
public Repository(MagazineContext context) { _context = context; _entities = context.Set <T>(); }
public HomeController(ILogger <HomeController> logger, MagazineContext context) { this.context = context; _logger = logger; }
public OrderRepository(MagazineContext context) : base(context) { _entities = context.Set <Order>(); }
public MagazinesController(MagazineContext context) { _context = context; }