public async Task <UrlInfo> Get(int id)
 {
     using (var context = new TourAgencyContext())
     {
         return(await context.UrlInfos.Include(r => r.UrlListInfos).FirstOrDefaultAsync(r => r.ButtonId == id));
     }
 }
Exemple #2
0
 public async Task <Information> GetId(int id)
 {
     using (var context = new TourAgencyContext())
     {
         return(await context.Information.FirstOrDefaultAsync(r => r.Id == id));
     }
 }
Exemple #3
0
 public async Task <List <StorageAPI.Models.Database.Slider> > Get()
 {
     using (var context = new TourAgencyContext())
     {
         return(await context.Slider.ToListAsync());
     }
 }
Exemple #4
0
        public async Task <List <Information> > GetIdSection(int id)
        {
            using (var context = new TourAgencyContext())
            {
                try
                {
                    Section elm = await context.Sections.Include(r => r.Disciples).FirstOrDefaultAsync(r => r.Id == id);

                    if (elm != null)
                    {
                        return(elm.Disciples.Where(r => r.IsPublick == true).Select(z => new Information()
                        {
                            Id = z.Id,
                            DateTime = z.DateTime,
                            SectionsId = z.SectionsId,
                            Info = z.Info,
                            Title = z.Title
                        }).ToList());
                    }
                }
                catch (Exception el)
                {
                }

                return(null);
            }
        }
Exemple #5
0
        public EFUnitOfWork(string connectionString)
        {
            db = new TourAgencyContext(connectionString);

            userManager   = new UserManager(new UserStore <User>(db));
            roleManager   = new UserRoleManager(new RoleStore <UserRole>(db));
            clientManager = new ClientManager(db);
        }
Exemple #6
0
 // DELETE api/<controller>/5
 public void Delete(long id)
 {
     using (var context = new TourAgencyContext())
     {
         context.User.Find(id).IfNotNull(x => context.User.Remove(x));
         context.SaveChanges();
     }
 }
Exemple #7
0
 // GET api/<controller>
 public IEnumerable <Test> Get(int limit, int offset)
 {
     limit %= 1000;
     using (var context = new TourAgencyContext())
     {
         var test = context.Test.ToList().Select(Test.CreateFromDb);
         return(context.Test.ToList().Select(Test.CreateFromDb));
     }
 }
Exemple #8
0
 public async Task <Information> Get(int id)
 {
     using (var context = new TourAgencyContext())
     {
         return(await context.Information.FirstOrDefaultAsync(r => r.ButtonId == id &&
                                                              string.IsNullOrEmpty(r.Cat) &&
                                                              r.IsPublick));
     }
 }
Exemple #9
0
 public async Task <IEnumerable <NewsModel> > Get(DataComModel model)
 {
     using (var context = new TourAgencyContext())
     {
         return(await context.NewsModel
                .AsNoTracking()
                .Where(r => r.Language == model.Language)
                .ToListAsync());
     }
 }
 public async Task <List <PassageImage> > Get(int id)
 {
     using (var context = new TourAgencyContext())
     {
         return(await context.PassageImages
                .AsNoTracking()
                .Include(r => r.imageLists)
                .Where(r => r.ButtonId == id)
                .ToListAsync());
     }
 }
Exemple #11
0
        // GET api/<controller>/5
        public Test Get(long id)
        {
            using (var context = new TourAgencyContext())
            {
                var dbTest = context.Test.Find(id);
                if (dbTest != null)
                {
                    return(Test.CreateFromDb(dbTest));
                }
            }

            return(null);
        }
Exemple #12
0
 public string GetFirstBisy()
 {
     using (var context = new TourAgencyContext())
     {
         try
         {
             return(context.VideoConnects.FirstOrDefault(f => !f.IsBusy)?.Name);
         }
         catch
         {
             return(null);
         }
     }
 }
Exemple #13
0
 public void SetLive(string value)
 {
     using (var context = new TourAgencyContext())
     {
         var str = context.LivesString.ToList();
         context.LivesString.RemoveRange(str);
         context.SaveChanges();
         context.LivesString.Add(new Live()
         {
             LiveString = value
         });
         context.SaveChanges();
     }
 }
Exemple #14
0
        public ExtendedUser Get([FromUri] long id)
        {
            using (var context = new TourAgencyContext())
            {
                var dbUser = context.User.Find(id);

                if (dbUser != null)
                {
                    return(StorageAPI.Models.ExtendedUser.CreateFromDbWithTests(dbUser));
                }
            }

            return(null);
        }
Exemple #15
0
        public User Auth([FromUri] string login, [FromUri] string password)
        {
            using (var context = new TourAgencyContext())
            {
                var hash   = Convert.ToBase64String(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(password)));
                var dbUser = context.User.FirstOrDefault(x => x.Login == login && x.Password == hash);

                if (dbUser != null)
                {
                    return(StorageAPI.Models.User.CreateFromDb(dbUser));
                }
            }

            return(null);
        }
Exemple #16
0
        // DELETE api/<controller>/5
        public void Delete(long id)
        {
            using (var context = new TourAgencyContext())
            {
                var dbNews = context.NewsModel.Find(id);

                if (dbNews == null)
                {
                    return;
                }

                context.NewsModel.Remove(dbNews);
                context.SaveChanges();
            }
        }
Exemple #17
0
        // DELETE api/<controller>/5
        public void Delete(long id)
        {
            using (var context = new TourAgencyContext())
            {
                var dbTest = context.Test.Find(id);

                if (dbTest == null)
                {
                    return;
                }

                context.Test.Remove(dbTest);
                context.SaveChanges();
            }
        }
Exemple #18
0
 public async Task <List <Information> > GetLents(int id)
 {
     try
     {
         using (var context = new TourAgencyContext())
         {
             return(await context.Information.Where(r => r.ButtonId == id &&
                                                    r.Cat == "ListModel" &&
                                                    r.IsPublick == true).ToListAsync());
         }
     }
     catch
     {
         return(null);
     }
 }
Exemple #19
0
        public async Task <string> GetVideoGuide()
        {
            try
            {
                using (var context = new TourAgencyContext())
                {
                    VideoGuideModel elm = await context.VideoGuideModels.FirstOrDefaultAsync();

                    if (elm != null)
                    {
                        return(elm.Path);
                    }
                }
            }
            catch { }
            return(string.Empty);
        }
        public async Task <List <Section> > Get(int id)
        {
            List <Section> list = null;

            using (var context = new TourAgencyContext())
            {
                list = await context.Sections.Include(r => r.Children).Where(r => r.ButtonId == id).ToListAsync();

                for (int i = 0; i < list.Count; i++)
                {
                    list[i].Disciples = null;
                    LoadSection(list[i].Children);
                }
            }

            return(list);
        }
Exemple #21
0
        public string Install()
        {
            try
            {
                using (TourAgencyContext context = new TourAgencyContext())
                {
                    context.LanguageModels.AddRange(new List <LanguageModel>()
                    {
                        new LanguageModel()
                        {
                            Name     = "Русский",
                            CodeLang = "RU",
                            IsActive = true
                        },
                        new LanguageModel()
                        {
                            Name     = "Aнглиский",
                            CodeLang = "EN",
                            IsActive = false
                        },
                        new LanguageModel()
                        {
                            Name     = "Китайский",
                            CodeLang = "CN",
                            IsActive = false
                        }
                    });

                    context.TerminalsModels.Add(new TerminalsModel()
                    {
                        TerminalId   = Guid.Parse("0f8fad5b-d9cb-469f-a165-70867728950e"),
                        Name         = "LoacalHost",
                        IsAutorizate = true
                    });

                    // сохраняем
                    context.SaveChanges();
                }
                return("Ок");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Exemple #22
0
 public bool SetVoit([FromUri] string title, [FromUri] int indexId)
 {
     try
     {
         using (var context = new TourAgencyContext())
         {
             var a = context.Test.FirstOrDefault(f => f.Question == title);
             if (a == null)
             {
                 return(false);
             }
             var models = new List <AnswerModel>();
             try
             {
                 models = JsonConvert.DeserializeObject <List <AnswerModel> >(a.Answer) ?? new List <AnswerModel>();
             }
             catch (Exception e)
             {
             }
             var model = models.FirstOrDefault(f => f.TitleTest == title);
             if (model == null)
             {
                 model             = new AnswerModel();
                 model.TitleTest   = title;
                 model.IndexAnswer = indexId;
                 model.Voits       = 1;
                 models.Add(model);
                 a.Answer = JsonConvert.SerializeObject(models);
                 context.Test.AddOrUpdate(a);
             }
             else
             {
                 model.Voits++;
                 a.Answer = JsonConvert.SerializeObject(models);
                 context.Test.AddOrUpdate(a);
             }
             context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemple #23
0
        public long Put([FromUri] long id, [FromBody] ExtendedUser value)
        {
            using (var context = new TourAgencyContext())
            {
                var dbUser = context.User.Find(id);

                if (dbUser == null)
                {
                    return(-1);
                }

                dbUser.Name     = value.Name;
                dbUser.Password = value.PasswordHash;

                context.SaveChanges();
                return(dbUser.Id);
            }
        }
Exemple #24
0
        // POST api/<controller>
        public long Post([FromBody] Test value)
        {
            using (var context = new TourAgencyContext())
            {
                var dbTest = new StorageAPI.Models.Database.Test()
                {
                    Answer    = String.Empty,
                    Question  = value.Question,
                    Responses = JsonConvert.SerializeObject(value.Responses),
                    Title     = value.Title,
                    Lang      = value.Lang,
                };

                context.Test.Add(dbTest);
                context.SaveChanges();
                return(dbTest.Id);
            }
        }
Exemple #25
0
        // POST api/<controller>
        public long Post([FromBody] News value)
        {
            using (var context = new TourAgencyContext())
            {
                var dbNews = new NewsModel
                {
                    AdvertisingImageUri = value.AdvertisingImageUri,
                    //Content = value.Content,
                    ContentType = value.ContentType,
                    IconUri     = value.IconUri,
                    Text        = value.Text
                };

                context.NewsModel.Add(dbNews);
                context.SaveChanges();

                return(dbNews.Id);
            }
        }
Exemple #26
0
 public async Task CallEnd(string name)
 {
     using (var context = new TourAgencyContext())
     {
         try
         {
             var admin = context.VideoConnects.FirstOrDefault(f => f.Name == name);
             if (admin == null)
             {
                 return;
             }
             admin.IsBusy = false;
             await context.SaveChangesAsync();
         }
         catch (Exception e)
         {
         }
     }
 }
Exemple #27
0
 public async Task AdminLeave(string name)
 {
     using (var context = new TourAgencyContext())
     {
         try
         {
             var admin = context.VideoConnects.FirstOrDefault(f => f.Name == name);
             if (admin == null)
             {
                 return;
             }
             context.VideoConnects.Remove(admin);
             await context.SaveChangesAsync();
         }
         catch
         {
         }
     }
 }
Exemple #28
0
        public async Task <bool> AddNewAdmin(string name)
        {
            using (var context = new TourAgencyContext())
            {
                try
                {
                    VideoConnect admin = new VideoConnect();
                    admin.Name   = name;
                    admin.IsBusy = false;
                    context.VideoConnects.Add(admin);
                    await context.SaveChangesAsync();

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }
Exemple #29
0
        // PUT api/<controller>/5
        public long Put(long id, [FromBody] Test value)
        {
            using (var context = new TourAgencyContext())
            {
                var dbTest = context.Test.Find(id);

                if (dbTest != null)
                {
                    dbTest.Answer    = value.Answer;
                    dbTest.Question  = value.Question;
                    dbTest.Responses = JsonConvert.SerializeObject(value.Responses);
                    dbTest.Title     = value.Title;
                    dbTest.Lang      = value.Lang;
                    context.SaveChanges();

                    return(dbTest.Id);
                }
            }

            return(-1);
        }
Exemple #30
0
        // PUT api/<controller>/5
        public long Put(long id, [FromBody] News value)
        {
            using (var context = new TourAgencyContext())
            {
                var dbNews = context.NewsModel.Find(id);

                if (dbNews != null)
                {
                    dbNews.AdvertisingImageUri = value.AdvertisingImageUri;
                    //dbNews.Content = value.Content;
                    dbNews.ContentType = value.ContentType;
                    dbNews.IconUri     = value.IconUri;
                    dbNews.Text        = value.Text;

                    context.SaveChanges();

                    return(dbNews.Id);
                }
            }

            return(-1);
        }