Exemplo n.º 1
0
 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);
        }
Exemplo n.º 3
0
 public CustomersController(CustomerContext context)
 {
     _context = context;
 }
Exemplo n.º 4
0
 public GetCustomerQueryHandler(CustomerContext context)
 {
     _context = context;
 }
Exemplo n.º 5
0
 public CustomerRepository(CustomerContext context, ILogger <CustomerRepository> logger)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
     _logger  = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Exemplo n.º 6
0
 public CustomerRepository(CustomerContext dbContext) => this._dbContext = dbContext;
Exemplo n.º 7
0
        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());
            }
        }
Exemplo n.º 8
0
 public CustomerManager(CustomerContext context)
 {
     _customerContext = context;
 }
Exemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 public CustomerRepository(CustomerContext context)
 {
     _context = context;
 }
Exemplo n.º 10
0
 public CustomerRepository(CustomerContext context, ILoggerFactory loggerFactory, IMapper mapper)
 {
     this._Context = context;
     this.mapper   = mapper;
     _Logger       = loggerFactory.CreateLogger("CustomerRepository");
 }
Exemplo n.º 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;
 }
Exemplo n.º 16
0
 public static void SignOut()
 {
     CustomerContext.DeleteCustomerCookie();
     FormsAuthentication.SignOut();
 }
Exemplo n.º 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();
 }
Exemplo n.º 19
0
 /// <summary>
 /// The reset.
 /// </summary>
 public void Reset()
 {
     CustomerContext.SetValue("costage", "0");
 }
Exemplo n.º 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();
        }
Exemplo n.º 21
0
        /// <summary>
        /// deserialize recently viewed.
        /// </summary>
        private void Initialize()
        {
            var value = CustomerContext.GetValue("costage");

            _stage = value.IsNullOrWhiteSpace() ? 0 : int.Parse(value);
        }
Exemplo n.º 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());
            }
        }
Exemplo n.º 23
0
 public UserRepository(CustomerContext context, ILoggerFactory loggerFactory)
 {
     this.context = context;
     this._Logger = loggerFactory.CreateLogger("UserRepository");
 }
Exemplo n.º 24
0
 public SalesTerritoryRepository(CustomerContext context) : base(context)
 {
 }
Exemplo n.º 25
0
        public ActionResult GetAll()
        {
            CustomerContext context = HttpContext.RequestServices.GetService(typeof(CustomerContext)) as CustomerContext;

            return(Ok(context.GetAllCustomers()));
        }
Exemplo n.º 26
0
 public CustomerService(CustomerContext context)
 {
     _dbContext = context;
 }
Exemplo n.º 27
0
 public TaxScheduleRepository(CustomerContext context) : base(context)
 {
 }
Exemplo n.º 28
0
 public Task <CustomerGraph> Customer([Inject] CustomerContext service) => service.GetCustomer(_dto.CustomerId);
Exemplo n.º 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"));
        }
Exemplo n.º 31
0
 public CustomerRepository()
 {
     context = new CustomerContext();
 }
 public CustomerController(CustomerContext context, IConfiguration configuration)
 {
     _context       = context;
     _configuration = configuration;
 }
Exemplo n.º 33
0
 public ProductsController(CustomerContext contex, IMapper mapper)
 {
     this.contex = contex;
     this.mapper = mapper;
 }
Exemplo n.º 34
0
 public Repository(CustomerContext customerContext)
 {
     CustomerContext = customerContext;
 }
Exemplo n.º 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));
 }
Exemplo n.º 37
0
 public CustomerRepository(CustomerContext context) : base(context)
 {
 }