Пример #1
0
        public async Task AddAllSalesChannelsToUserAsync(string userID)
        {
            var salesChannels = await FindSalesChannelsAvailableByUserAsync(userID);

            foreach (SalesChannel salesChannel in salesChannels)
            {
                SalesChannelUser salesChannelUser = new SalesChannelUser
                {
                    SalesChannelID = salesChannel.SalesChannelID,
                    UserID         = userID
                };

                await CreateAsync(salesChannelUser);
            }
        }
Пример #2
0
        public void Create(SalesChannelUser salesChannelUserToAdd)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try
            {
                db.SalesChannelUsers.Add(salesChannelUserToAdd);
                db.SaveChanges();

                timespan.Stop();
                log.TraceApi("SQL Database", "SalesChannelUserRepository.Create", timespan.Elapsed, "salesChannelUserToAdd={0}", salesChannelUserToAdd);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in SalesChannelUserRepository.Create(salesChannelUserToAdd={0})", salesChannelUserToAdd);
                throw;
            }
        }
Пример #3
0
        public void Delete(int salesChannelUserID)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try
            {
                SalesChannelUser salesChannelUser = db.SalesChannelUsers.Find(salesChannelUserID);
                db.SalesChannelUsers.Remove(salesChannelUser);
                db.SaveChanges();

                timespan.Stop();
                log.TraceApi("SQL Database", "SalesChannelUserRepository.Delete", timespan.Elapsed, "salesChannelUserID={0}", salesChannelUserID);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in SalesChannelUserRepository.Delete(salesChannelUserID={0})", salesChannelUserID);
                throw;
            }
        }