public DatabaseContext()
 {
     Concerts = new ConcertContext();
     Tickets = new ConcertTicketContext();
     Customers = new CustomerContext();
     Purchase = new PurchaseTicketsModel();
     Venues = new VenueContext();
 }
        public HttpResponseMessage SavenotificationResponse(NotificationMessageReceived NotificationMessageReceived)
        {
            using (var db = new CustomerContext())
            {
                db.NotificationMessageReceived.Add(NotificationMessageReceived);
                db.SaveChanges();

                string message = System.Configuration.ConfigurationManager.AppSettings["AckMessage"];
                NotificationService.SendSMS("FromNo", NotificationMessageReceived.From, message);
            }

            return Request.CreateResponse(HttpStatusCode.OK, NotificationMessageReceived);
        }
 public CustomersController(CustomerContext context)
 {
     _context = context;
 }
Example #4
0
 public GetCustomerQueryHandler(CustomerContext context)
 {
     _context = context;
 }
Example #5
0
 public CustomerRepository(CustomerContext context, ILogger <CustomerRepository> logger)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
     _logger  = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Example #6
0
 public CustomerRepository(CustomerContext dbContext) => this._dbContext = dbContext;
        public async Task Can_add_update_untracked_properties_async()
        {
            var options = Fixture.CreateOptions();

            var customer = new Customer {
                Id = 42, Name = "Theon"
            };

            using (var context = new CustomerContext(options))
            {
                await context.Database.EnsureCreatedAsync();

                var entry = context.Add(customer);

                await context.SaveChangesAsync();

                var document = entry.Property <JObject>("__jObject").CurrentValue;
                Assert.NotNull(document);
                Assert.Equal("Theon", document["Name"]);

                context.Remove(customer);

                await context.SaveChangesAsync();
            }

            using (var context = new CustomerContext(options))
            {
                Assert.Empty(await context.Set <Customer>().ToListAsync());

                var entry = context.Add(customer);

                entry.Property <JObject>("__jObject").CurrentValue = new JObject
                {
                    ["key1"] = "value1"
                };

                await context.SaveChangesAsync();

                var document = entry.Property <JObject>("__jObject").CurrentValue;
                Assert.NotNull(document);
                Assert.Equal("Theon", document["Name"]);
                Assert.Equal("value1", document["key1"]);

                document["key2"] = "value2";
                entry.State      = EntityState.Modified;
                await context.SaveChangesAsync();
            }

            using (var context = new CustomerContext(options))
            {
                var customerFromStore = await context.Set <Customer>().SingleAsync();

                Assert.Equal(42, customerFromStore.Id);
                Assert.Equal("Theon", customerFromStore.Name);

                var entry    = context.Entry(customerFromStore);
                var document = entry.Property <JObject>("__jObject").CurrentValue;
                Assert.Equal("value1", document["key1"]);
                Assert.Equal("value2", document["key2"]);

                document["key1"]       = "value1.1";
                customerFromStore.Name = "Theon Greyjoy";

                await context.SaveChangesAsync();
            }

            using (var context = new CustomerContext(options))
            {
                var customerFromStore = await context.Set <Customer>().SingleAsync();

                Assert.Equal("Theon Greyjoy", customerFromStore.Name);

                var entry    = context.Entry(customerFromStore);
                var document = entry.Property <JObject>("__jObject").CurrentValue;
                Assert.Equal("value1.1", document["key1"]);
                Assert.Equal("value2", document["key2"]);

                context.Remove(customerFromStore);

                await context.SaveChangesAsync();
            }

            using (var context = new CustomerContext(options))
            {
                Assert.Empty(await context.Set <Customer>().ToListAsync());
            }
        }
 public CustomerManager(CustomerContext context)
 {
     _customerContext = context;
 }
Example #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 public CustomerRepository(CustomerContext context)
 {
     _context = context;
 }
 public CustomerRepository(CustomerContext context, ILoggerFactory loggerFactory, IMapper mapper)
 {
     this._Context = context;
     this.mapper   = mapper;
     _Logger       = loggerFactory.CreateLogger("CustomerRepository");
 }
Example #11
0
 public EFCustomerRepo()
 {
     CustDB = new CustomerContext();
     CustDB.Configuration.LazyLoadingEnabled = false;
 }
 public CustomerWithLastName(CustomerContext context)
 {
     this.context = context;
 }
 public static bool NotificationLogAdd(int Type, string SentTo, string FirstName, string Surname, string SentFrom, string Message, string Status, string LogComment, bool Seed, bool TestMode)
 {
     try
     {
         using (CustomerContext db = new CustomerContext())
         {
             NotificationLog notificationlog = new NotificationLog();
             notificationlog.Type = Type;
             notificationlog.SentTo = SentTo;
             notificationlog.FirstName = FirstName;
             notificationlog.Surname = Surname;
             notificationlog.SentFrom = SentFrom;
             notificationlog.Message = Message;
             notificationlog.Status = Status;
             notificationlog.LogComment = LogComment;
             notificationlog.Seed = Seed;
             notificationlog.TestMode = TestMode;
             db.NotificationLog.Add(notificationlog);
             db.SaveChanges();
         }
         return true;
     }
     catch (Exception ex)
     {
         return false;
     }
 }
        public bool CheckExists(NotificationSearch NotificationSearch)
        {
            var db = new CustomerContext();
            bool flag = false;
            var NotificationDataList = this.NotificationDataList(NotificationSearch);
            try
            {
                foreach (var item in NotificationDataList)
                {
                    if (!string.IsNullOrEmpty(item.Email))
                    {
                        var logemail = db.NotificationLog.Where(x => x.SentTo.Trim().ToLower() == item.Email.Trim().ToLower()).Count();
                        if (logemail > 0)
                        {
                            flag = false;
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(item.MobileNo))
                    {
                        var logemail = db.NotificationLog.Where(x => x.SentTo == item.MobileNo).Count();
                        if (logemail > 0)
                        {
                            flag = false;
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {

            }
            return flag;
        }
 public CustomerService(CustomerContext customerContext)
 {
     this.customerContext = customerContext;
 }
Example #16
0
 public static void SignOut()
 {
     CustomerContext.DeleteCustomerCookie();
     FormsAuthentication.SignOut();
 }
Example #17
0
 /// <summary>
 /// The set stage.
 /// </summary>
 /// <param name="stage">
 /// The stage.
 /// </param>
 public void SetStage(int stage)
 {
     CustomerContext.SetValue("costage", stage.ToString(CultureInfo.InvariantCulture));
 }
 public NotificationService()
 {
     this._CustomerService = new CustomerContext();
 }
Example #19
0
 /// <summary>
 /// The reset.
 /// </summary>
 public void Reset()
 {
     CustomerContext.SetValue("costage", "0");
 }
Example #20
0
        private void SaveCustomer(CustomerPoco customer, PrimaryKeyId orgId)
        {
            var user = _userManager.FindByEmailAsync(customer.Email)
                       .GetAwaiter()
                       .GetResult();

            if (user == null)
            {
                user = new SiteUser
                {
                    CreationDate = DateTime.UtcNow,
                    Username     = customer.Email,
                    Email        = customer.Email,
                    FirstName    = customer.FirstName,
                    LastName     = customer.LastName,
                    IsApproved   = true
                };

                var result = _userManager.CreateAsync(user, "Episerver123!")
                             .GetAwaiter()
                             .GetResult();

                if (!result.Succeeded)
                {
                    return;
                }
            }

            foreach (var role in customer.Roles)
            {
                if (!_roleManager.RoleExistsAsync(role)
                    .GetAwaiter()
                    .GetResult())
                {
                    var createdRole = new IdentityRole(role);

                    var roleResult = _roleManager.CreateAsync(createdRole)
                                     .GetAwaiter()
                                     .GetResult();

                    if (!roleResult.Succeeded)
                    {
                        continue;
                    }
                    _userManager.AddToRoleAsync(user.Id, role)
                    .GetAwaiter()
                    .GetResult();
                }
            }

            FoundationContact foundationContact;
            var contact = CustomerContext.GetContactByUserId($"String:{customer.Email}");

            if (contact == null)
            {
                foundationContact        = FoundationContact.New();
                foundationContact.UserId = customer.Email;
                foundationContact.Email  = customer.Email;
            }
            else
            {
                foundationContact = new FoundationContact(contact);
            }

            foundationContact.FirstName            = customer.FirstName;
            foundationContact.LastName             = customer.LastName;
            foundationContact.FullName             = $"{foundationContact.FirstName} {foundationContact.LastName}";
            foundationContact.RegistrationSource   = "Imported customer";
            foundationContact.AcceptMarketingEmail = true;
            foundationContact.ConsentUpdated       = DateTime.UtcNow;
            foundationContact.UserRole             = customer.B2BRole;
            foundationContact.UserLocationId       = customer.Location;
            foundationContact.DemoUserTitle        = customer.DemoUserTitle;
            foundationContact.DemoUserDescription  = customer.DemoUserDescription;
            foundationContact.ShowInDemoUserMenu   = customer.ShowInDemoUserMenu == 0 ? 1 : customer.ShowInDemoUserMenu;
            foundationContact.DemoSortOrder        = customer.DemoSortOrder;

            if (orgId != PrimaryKeyId.Empty)
            {
                foundationContact.Contact.OwnerId = orgId;
            }
            foundationContact.SaveChanges();

            MapAddressesFromCustomerToContact(customer, foundationContact.Contact);
            MapCreditCardsFromCustomerToContact(customer.CreditCards, foundationContact.Contact);
            foundationContact.SaveChanges();
        }
Example #21
0
        /// <summary>
        /// deserialize recently viewed.
        /// </summary>
        private void Initialize()
        {
            var value = CustomerContext.GetValue("costage");

            _stage = value.IsNullOrWhiteSpace() ? 0 : int.Parse(value);
        }
Example #22
0
        public async Task Can_add_update_delete_detached_entity_end_to_end_async()
        {
            var options = Fixture.CreateOptions();

            var customer = new Customer {
                Id = 42, Name = "Theon"
            };
            string storeId = null;

            using (var context = new CustomerContext(options))
            {
                await context.Database.EnsureCreatedAsync();

                var entry = context.Add(customer);

                await context.SaveChangesAsync();

                context.Add(customer);

                storeId = entry.Property <string>("id").CurrentValue;
            }

            Assert.NotNull(storeId);

            using (var context = new CustomerContext(options))
            {
                var customerFromStore = await context.Set <Customer>().SingleAsync();

                Assert.Equal(42, customerFromStore.Id);
                Assert.Equal("Theon", customerFromStore.Name);
            }

            using (var context = new CustomerContext(options))
            {
                customer.Name = "Theon Greyjoy";

                var entry = context.Entry(customer);
                entry.Property <string>("id").CurrentValue = storeId;

                entry.State = EntityState.Modified;

                await context.SaveChangesAsync();
            }

            using (var context = new CustomerContext(options))
            {
                var customerFromStore = context.Set <Customer>().Single();

                Assert.Equal(42, customerFromStore.Id);
                Assert.Equal("Theon Greyjoy", customerFromStore.Name);
            }

            using (var context = new CustomerContext(options))
            {
                var entry = context.Entry(customer);
                entry.Property <string>("id").CurrentValue = storeId;
                entry.State = EntityState.Deleted;

                await context.SaveChangesAsync();
            }

            using (var context = new CustomerContext(options))
            {
                Assert.Empty(await context.Set <Customer>().ToListAsync());
            }
        }
 public UserRepository(CustomerContext context, ILoggerFactory loggerFactory)
 {
     this.context = context;
     this._Logger = loggerFactory.CreateLogger("UserRepository");
 }
Example #24
0
 public SalesTerritoryRepository(CustomerContext context) : base(context)
 {
 }
        public ActionResult GetAll()
        {
            CustomerContext context = HttpContext.RequestServices.GetService(typeof(CustomerContext)) as CustomerContext;

            return(Ok(context.GetAllCustomers()));
        }
 public CustomerService(CustomerContext context)
 {
     _dbContext = context;
 }
Example #27
0
 public TaxScheduleRepository(CustomerContext context) : base(context)
 {
 }
Example #28
0
 public Task <CustomerGraph> Customer([Inject] CustomerContext service) => service.GetCustomer(_dto.CustomerId);
Example #29
0
 public CustomersController(CustomerContext dbContext, IValidator <CustomerDto> validator)
 {
     _dbContext = dbContext;
     _validator = validator;
 }
        public ActionResult Create(int CustomerId, string CustomerName, int Age, bool StudentStatus, float Bill, bool Disable, bool CustomerisSubscribedToNewsLetter, int membershipTypeId, List <Movie> movies)
        {
            // Customer customer = new Customer();
            //// Movie Movie = new Movie();

            // customer.id = CustomerId;

            // customer.Name = CustomerName;

            // customer.IsSubscribedToNewsletter = CustomerisSubscribedToNewsLetter;
            // customer.CurrentMembershipTypeId = membershipTypeId;

            using (var customerContext = new CustomerContext())
            {
                Customer customer = new Customer()
                {
                    id                       = CustomerId,
                    Name                     = CustomerName,
                    Age                      = Age,
                    StudentStatus            = StudentStatus,
                    Bill                     = Bill,
                    Disable                  = Disable,
                    IsSubscribedToNewsletter = CustomerisSubscribedToNewsLetter,
                    CurrentMembershipTypeId  = membershipTypeId,
                    Movies                   = movies
                };
                //for (int i = 0; i < movies.Count; i++)
                //{
                //    customer.Movies.Add(movies[i]);
                //}
                customerContext.Customers.Attach(customer);
                customerContext.Customers.Add(customer);
                customerContext.SaveChanges();

                //iCustomerRepository.InsertCustomer(customer);
                // imovieRepository.InsertMovie(movie);

                // iCustomerRepository.Save();
            }

            //for (int i = 0; i < imovieRepository.GetMovies().Count(); i++)
            //{
            //    if (imovieRepository.GetMovies().ToList()[i].Id == movieId)
            //    {
            //        customer.Movies.Add(imovieRepository.GetMovies().ToList()[i]);
            //    }
            //    //if (movieObj.Id == movieId)
            //    //{
            //    //    customer.Movies.Add(movieObj);
            //    //}

            //}

            // customer.Movies.Add(movie);
            // movie.Customers.Add(customer);


            // iCustomerRepository.InsertCustomer(customer);
            //// imovieRepository.InsertMovie(movie);

            // iCustomerRepository.Save();
            // imovieRepository.Save();

            return(RedirectToAction("Index"));
        }
Example #31
0
 public CustomerRepository()
 {
     context = new CustomerContext();
 }
 public CustomerController(CustomerContext context, IConfiguration configuration)
 {
     _context       = context;
     _configuration = configuration;
 }
 public ProductsController(CustomerContext contex, IMapper mapper)
 {
     this.contex = contex;
     this.mapper = mapper;
 }
 public Repository(CustomerContext customerContext)
 {
     CustomerContext = customerContext;
 }
Example #35
0
        private async Task SnapshotRepository(IServiceProvider provider)
        {
            CustomerContext context = provider.GetRequiredService <CustomerContext>();

            PostTestCustomers = await context.Customers.ToArrayAsync();
        }
 /// <returns>OK</returns>
 /// <exception cref="SwaggerException">A server side error occurred.</exception>
 public System.Threading.Tasks.Task <ApiResponseOfMyInfoViewModel> GetInfoAsync(CustomerContext context)
 {
     return(GetInfoAsync(context, System.Threading.CancellationToken.None));
 }
Example #37
0
 public CustomerRepository(CustomerContext context) : base(context)
 {
 }