Ejemplo n.º 1
0
        public object Any(User request)
        {
            TableRepository tableRepository = new TableRepository();
            var userQuery = tableRepository.GetTable(Tables.Users).CreateQuery<UserEntry>();

            string username = request.Username;
            username = TableEntityHelper.RemoveDiacritics(username);
            username = TableEntityHelper.ToAzureKeyString(username);

            var user = (from k in userQuery
                        where k.RowKey == username
                        select k).FirstOrDefault();

            if (user == null)
                return HttpError.NotFound(username + " do not exist");

            var badges = tableRepository.Get<UserBadgeEntry>(Tables.UserBadges, user.GetUserId().ToString());

            // "No similar question found... yet !"
            return new UserResponse
            {
                Created = user.CreatedDate,
                Badges = badges.Select(k => new BadgeResponse
                {
                    Name = k.GetName(),
                    Awarded = k.Awarded,
                }).ToArray()
            };
        }
Ejemplo n.º 2
0
        public override int Add()
        {
            TElementType element = NewElement();

            TableRepository.Add(element);
            Items.Add(element);
            return(element.Id);
        }
Ejemplo n.º 3
0
        public void NotificationNull()
        {
            //Arrange | Act
            var repository = new TableRepository(GetPostgreSettings, null);

            //Assert
            Assert.NotNull(repository);
        }
        public void does_build_merge_for_table_with_no_schema_defined()
        {
            var tableRepository = new TableRepository(Path.Combine(Directories.GetSampleSolution(), @"NestedProjects\Nested\bin\Debug\Nested.dacpac"));
            var mergeRepository = new MergeStatementRepository(tableRepository, Path.Combine(Directories.GetSampleSolution(), @"NestedProjects\Nested\ABC\DEF\Script.PostDeploy.sql"));
            var merge           = mergeRepository.Get().FirstOrDefault(p => p.Name.Value == "NoSchema");

            Assert.IsNotNull(merge);
        }
Ejemplo n.º 5
0
        public TableBusinessModel()
        {
            _playerBusinessModel = new PlayerBusinessModel();
            _tableRepository     = new TableRepository(new SessionBusinessModel());

            EventAggregator.Resolve <PlayerJoinedTable>().Subscribe(PlayerJoinedTableEvent);
            EventAggregator.Resolve <PlayerLeftTable>().Subscribe(PlayerLeftTableEvent);
        }
Ejemplo n.º 6
0
        public ActionResult GetSingle()
        {
            // Создайте объект операции извлечения, который принимает объект сущности, производный от TableEntity. Первый параметр — ключ раздела partitionKey, а второй — ключ строки rowKey. Используя класс CustomerEntity и данные, представленные в разделе Добавление пакета сущностей в таблицу, следующий фрагмент кода направляет запрос к таблице на получение сущности CustomerEntity, свойство partitionKey которой имеет значение Smith, а свойство rowKey — значение Ben
            string         c        = _configuration.GetConnectionString("start1storage_AzureStorageConnectionString");
            CustomerEntity customer = TableRepository.ReadCustomer(c, _tableName, "Smith", "Ben");

            return(View(customer));
        }
Ejemplo n.º 7
0
        public ActionResult DeleteEntity()
        {
            string c = _configuration.GetConnectionString("start1storage_AzureStorageConnectionString");

            ViewBag.TableName = _tableName;
            ViewBag.Result    = TableRepository.DeleteCustomer(c, _tableName, "Smith", "Ben");
            return(View());
        }
 public AttributedDocumentRepository(CloudStorageAccount storageAccount, IDocumentSerializer?serializer = default)
     : base(storageAccount,
            TableRepository.GetDefaultTableName <T>(),
            PartitionKeyAttribute.CreateCompiledAccessor <T>(),
            RowKeyAttribute.CreateCompiledAccessor <T>(),
            serializer ?? DocumentSerializer.Default)
 {
 }
Ejemplo n.º 9
0
 public ActionResult Index(Table tab)
 {
     if (ModelState.IsValid)
     {
         TableRepository.AddPerson(tab);
     }
     return(View());
 }
Ejemplo n.º 10
0
        public void Delete(int id)
        {
            var tr    = new TableRepository(_context);
            var table = tr.GetTableById(id);
            var tm    = new TableModification(_context);

            tm.DeleteTable(table);
        }
Ejemplo n.º 11
0
        public void IsExistNoteById_Test()
        {
            var repo = new TableRepository();

            var r = repo.IsExistNoteById(1);

            Assert.AreEqual(true, r); // 현재 시점에서는 통과
        }
Ejemplo n.º 12
0
        public void does_not_build_merge_for_table_with_no_inline_table()
        {
            var tableRepository = new TableRepository(GetPath());
            var mergeRepository = new MergeStatementRepository(tableRepository, Path.Combine(Directories.GetSampleSolution(), @"NestedProjects\Nested\ABC\DEF\Script.PostDeploy.sql"));
            var merge           = mergeRepository.Get().FirstOrDefault(p => p.Name.Value == "NoInlineTable");

            Assert.IsNull(merge);
        }
Ejemplo n.º 13
0
        public override TElementType Add(params object[] values)
        {
            TElementType element = NewElement(values);

            TableRepository.Add(element);
            Items.Add(element);
            return(element);
        }
Ejemplo n.º 14
0
 public void CreateForQuestion(TableRepository tableRepository, Guid userId, Guid questionId)
 {
     UserBadgeEntry badge = new UserBadgeEntry(userId, Name)
                            {
                                 QuestionId = questionId,
                             };
     tableRepository.InsertOrMerge(badge, Tables.UserBadges);
 }
Ejemplo n.º 15
0
        private async Task <Option <Table, Error> > CheckIfNumberIsNotTaken(AddTable command)
        {
            var table = await TableRepository
                        .GetByNumber(command.Number);

            return(table
                   .SomeWhen(t => !t.HasValue, Error.Conflict($"Table number '{command.Number}' is already taken."))
                   .Map(_ => Mapper.Map <Table>(command)));
        }
Ejemplo n.º 16
0
 public UnitOfWork(CoffeeShopContext context)
 {
     _context = context;
     Table    = new TableRepository(_context);
     User     = new UserRepository(_context);
     Category = new CategoryRepository(_context);
     Foods    = new FoodsRepository(_context);
     Images   = new ImageRepository(_context);
 }
Ejemplo n.º 17
0
        public void CreateForQuestion(TableRepository tableRepository, Guid userId, Guid questionId)
        {
            UserBadgeEntry badge = new UserBadgeEntry(userId, Name)
            {
                QuestionId = questionId,
            };

            tableRepository.InsertOrMerge(badge, Tables.UserBadges);
        }
Ejemplo n.º 18
0
        public DataMonitorView()
        {
            InitializeComponent();

            _tableRepository = new TableRepository(AppContext.Instance);
            _dataRepository  = new DataRepository(AppContext.Instance);

            InitData();
        }
Ejemplo n.º 19
0
 public void CreateIfNotExist(TableRepository tableRepository, Guid userId)
 {
     UserBadgeEntry badge = tableRepository.Get<UserBadgeEntry>(Tables.UserBadges, userId, Name);
     if (badge == null)
     {
         badge = new UserBadgeEntry(userId, Name);
         tableRepository.InsertOrMerge(badge, Tables.UserBadges);
     }
 }
Ejemplo n.º 20
0
 public OrderViewModel(MainViewModel mainViewModel)
 {
     CurrentViewModel       = new GroupItemsViewModel(this);
     _mainViewModel         = mainViewModel;
     _orderDetailRepository = new OrderDetailRepository(_connectionString);
     _orderRepository       = new OrderRepository(_connectionString);
     _tableRepository       = new TableRepository(_connectionString);
     _billRepositary        = new BillRepository(_connectionString);
 }
        public void LoadAllTables()
        {
            TableRepository.LoadSingleFile(@"..\..\..\Tables\treasure table.json", new JSONLoader());
            TableRepository.LoadSingleFile(@"..\..\..\Tables\magic base.json", new JSONLoader());
            TableRepository.LoadAllMatchingStringFromDirectory(@"..\..\..\Tables", @"*special abilities*", new JSONLoader());
            var baseTable = TableRepository.GetTableFromString("treasure table");

            TableRepository.GetTableFromString("armor special abilities").Accept(new PrintEntireTreeVisitor());
            TableRepository.GetTableFromString("shield special abilities").Accept(new PrintEntireTreeVisitor());
        }
Ejemplo n.º 22
0
        public Table(int wareId)
        {
            ITableRepository tr          = new TableRepository();
            Table            tableToLoad = tr.LoadTable(wareId);

            WareId   = tableToLoad.WareId;
            Length   = tableToLoad.Length;
            Width    = tableToLoad.Width;
            Quantity = 1;
        }
Ejemplo n.º 23
0
        private void Add_Table_Click(object sender, RoutedEventArgs e)
        {
            Table table = new Table()
            {
                TableInfo = TableInfoBox.Text
            };
            ITableRepository repository = new TableRepository();

            repository.CreateTable(table);
        }
Ejemplo n.º 24
0
        private UserCard CreateUserCard(TableRepository tableRepository, Guid creatorId)
        {
            UserEntry user = tableRepository.Get <UserEntry>(Tables.Users, creatorId.ToString())?.FirstOrDefault();

            return(new UserCard
            {
                Id = creatorId,
                Username = user?.UserName
            });
        }
        public void LoadTables()
        {
            TableRepository.LoadSingleFile(@"..\..\..\Tables\treasure table.json", new JSONLoader());
            TableRepository.LoadSingleFile(@"..\..\..\Tables\magic base.json", new JSONLoader());
            TableRepository.LoadAllMatchingStringFromDirectory(@"..\..\..\Tables", @"*special abilities*", new JSONLoader());

            var baseTable = TableRepository.GetTableFromString("treasure table");

            Assert.IsNotNull(baseTable);
        }
Ejemplo n.º 26
0
        public void sets_merge_options_to_show_missing_delete_clause()
        {
            var tableRepository = new TableRepository(GetPath());
            var mergeRepository = new MergeStatementRepository(tableRepository, Path.Combine(Directories.GetSampleSolution(), @"NestedProjects\Nested\ABC\DEF\Script.PostDeploy.sql"));
            var merge           = mergeRepository.Get().FirstOrDefault(p => p.Name.Value == "NoDelete");

            Assert.IsFalse(merge.Option.HasDelete);
            Assert.IsTrue(merge.Option.HasInsert);
            Assert.IsTrue(merge.Option.HasUpdate);
        }
Ejemplo n.º 27
0
        public override void Delete(int id)
        {
            TElementType element = Items.Find(e => e.Id == id);

            if (element != null)
            {
                Items.Remove(element);
            }
            TableRepository.Remove(id);
        }
Ejemplo n.º 28
0
        public void CreateIfNotExist(TableRepository tableRepository, Guid userId)
        {
            UserBadgeEntry badge = tableRepository.Get <UserBadgeEntry>(Tables.UserBadges, userId, Name);

            if (badge == null)
            {
                badge = new UserBadgeEntry(userId, Name);
                tableRepository.InsertOrMerge(badge, Tables.UserBadges);
            }
        }
Ejemplo n.º 29
0
 public ActionResult TruncateTable(TableModel model)
 {
     if (model.PostedTable != null && model.PostedTable.Name.Any())
     {
         var names = string.Join(",", model.PostedTable.Name.Select(c => c.Trim()));
         TableRepository.Truncate(names);
         ViewBag.Message = "Truncate thành công";
     }
     return(TruncateTable());
 }
Ejemplo n.º 30
0
        public override async Task <IEnumerable <TicketsPool> > Handle(GetEventsQuery request, CancellationToken cancellationToken)
        {
            var repo = new TableRepository <TicketsPool>(); //use ioc

            var allEvents = await repo.GetAll();

            var events = allEvents.OrderBy(ev => ev.EventName);

            return(events);
        }
Ejemplo n.º 31
0
        private void FirstStart()
        {
            ModelContainer         cont                   = new ModelContainer();
            BranchRepository       branchRepository       = new BranchRepository(cont);
            CategoryRepository     categoryRepository     = new CategoryRepository(cont);
            CompanyOwnerRepository companyOwnerRepository = new CompanyOwnerRepository(cont);
            PersonRepository       personRepository       = new PersonRepository(cont);
            PositionRepository     positionRepository     = new PositionRepository(cont);
            RoomRepository         roomRepository         = new RoomRepository(cont);
            TableRepository        tableRepository        = new TableRepository(cont);
            ClientRepository       clientRepository       = new ClientRepository(cont);

            if (positionRepository.Positions().Count() == 0)
            {
                positionRepository.AddPosition("Суперпользователь", true, true, true, true, true, true);
            }

            CompanyOwner co = new CompanyOwner();

            if (personRepository.Persones().Count() == 0)
            {
                co = companyOwnerRepository.AddCompanyOwner("Суперпользователь", "", "", "", "", "super", "super".GetHashCode().ToString(), "", "", "",
                                                            positionRepository.GetPositionByName("Суперпользователь"));
            }

            Branch b = new Branch();

            if (branchRepository.Branches().Count() == 0)
            {
                b = branchRepository.AddBranch("", "", DateTime.Now, DateTime.Now, "", "", "", "", "", co, null);
            }

            Room r = new Room();

            if (roomRepository.Rooms().Count() == 0)
            {
                r = roomRepository.AddRoom("", b);
            }

            if (categoryRepository.Categotyes().Count() == 0)
            {
                categoryRepository.AddCategory("");
            }

            if (tableRepository.Tables().Count() == 0)
            {
                tableRepository.AddTable(1, "", r);
            }

            if (clientRepository.Clients().Count() == 0)
            {
                clientRepository.AddClient("Клиент", "", "", "", "", "", "", "", "", "", "", "");
            }
        }
Ejemplo n.º 32
0
        public void Get_All_Photos_Count()
        {
            var tableRepository = new TableRepository();
            var blobRepository  = new BlobRepository();
            var visionService   = new VisionService();
            var photoService    = new PhotoService(tableRepository, blobRepository, visionService);

            var photos = photoService.GetAll();

            Assert.IsTrue(photos.Count > 0);
        }
Ejemplo n.º 33
0
        private void btnGetTables_Click(object sender, EventArgs e)
        {
            var tables = TableRepository.GetTables("MordorEV").ToList();

            clbTableList.Items.Clear();

            foreach (var table in tables)
            {
                clbTableList.Items.Add(table, CheckState.Unchecked);
            }
        }
Ejemplo n.º 34
0
        public object Any(Ask request)
        {
            AskResponse response = new AskResponse();
            response.Result = ErrorCode.OK;

            Guid creatorId = UserSession.GetUserId();

            DateTime dateTime = DateTime.UtcNow;
            QuestionEntry questionEntry = new QuestionEntry(creatorId, Guid.NewGuid())
            {
                Title = request.Title,
                Detail = request.Detail,
                Creation = dateTime,
                Modification = dateTime,
                Tags = string.Join(",", request.Tags).ToLowerInvariant()
            };

            TableRepository tableRepository = new TableRepository();
            tableRepository.InsertOrReplace(questionEntry, Tables.Questions);

            IndexHelper.CreateIndex(questionEntry.GetId(), request.Title + " " + questionEntry.Tags, Tables.Questions);

            return response;
        }
Ejemplo n.º 35
0
        public object Any(Vote request)
        {
            Guid userId = UserSession.GetUserId();

            VoteResponse response = new VoteResponse
            {
                Result = ErrorCode.OK,
            };

            TableRepository tableRepository = new TableRepository();

            UserQuestionEntry userQuestionEntry = tableRepository.Get<UserQuestionEntry>(Tables.UserQuestion, request.QuestionId, userId);

            // Création d'un nouveau vote
            if (userQuestionEntry == null)
            {
                DateTime dateTime = DateTime.UtcNow;
                userQuestionEntry = new UserQuestionEntry(request.QuestionId, userId)
                {
                    Creation = dateTime,
                    Modification = dateTime
                };
            }
            else
            {
                userQuestionEntry.Modification = DateTime.UtcNow;
            }

            Guid target = request.VoteTarget == VoteTarget.Question ? request.QuestionId : request.OwnerId;

            HashSet<string> votesUp = new HashSet<string>(userQuestionEntry.VotesUp?.Split('|') ?? new string[] { });
            HashSet<string> votesDown = new HashSet<string>(userQuestionEntry.VotesDown?.Split('|') ?? new string[] { });

            VoteKind oldValue = VoteKind.None;
            if (votesUp.Contains(target.ToString()))
                oldValue = VoteKind.Up;
            else if (votesDown.Contains(target.ToString()))
                oldValue = VoteKind.Down;

            response.VoteKind = request.VoteKind;

            votesUp.Remove(target.ToString());
            votesDown.Remove(target.ToString());

            if (response.VoteKind == oldValue) response.VoteKind = VoteKind.None;
            else
            {
                switch (response.VoteKind)
                {
                    case VoteKind.Up:
                        votesUp.Add(target.ToString());
                        break;
                    case VoteKind.Down:
                        votesDown.Add(target.ToString());
                        break;
                }
            }

            userQuestionEntry.VotesUp = votesUp.Join("|");
            userQuestionEntry.VotesDown = votesDown.Join("|");

            if (request.VoteTarget == VoteTarget.Answer)
            {
                AnswerEntry answerEntry = tableRepository.Get<AnswerEntry>(Tables.Answers, request.QuestionId, request.OwnerId);
                answerEntry.Votes -= (int)oldValue;
                answerEntry.Votes += (int)response.VoteKind;
                tableRepository.InsertOrMerge(answerEntry, Tables.Answers);
                response.VoteValue = answerEntry.Votes;

                // badges
                if (response.VoteKind == VoteKind.Up)
                {
                    switch (answerEntry.Votes)
                    {
                        case 1: AllBadges.Approved.CreateIfNotExist(tableRepository, answerEntry.GetAnswerOwnerId()); break;
                        case 10: AllBadges.NiceAnswer.CreateForQuestion(tableRepository, answerEntry.GetAnswerOwnerId(), request.QuestionId); break;
                        case 25: AllBadges.GoodAnswer.CreateForQuestion(tableRepository, answerEntry.GetAnswerOwnerId(), request.QuestionId); break;
                        case 100: AllBadges.GreatAnswer.CreateForQuestion(tableRepository, answerEntry.GetAnswerOwnerId(), request.QuestionId); break;
                    }
                }
            }
            else
            {
                QuestionEntry questionEntry = tableRepository.Get<QuestionEntry>(Tables.Questions, request.OwnerId, request.QuestionId);
                questionEntry.Votes -= (int)oldValue;
                questionEntry.Votes += (int)response.VoteKind;
                tableRepository.InsertOrMerge(questionEntry, Tables.Questions);
                response.VoteValue = questionEntry.Votes;

                // badges
                if (response.VoteKind == VoteKind.Up)
                {
                    switch (questionEntry.Votes)
                    {
                        case 1: AllBadges.Padawan.CreateIfNotExist(tableRepository, questionEntry.GetOwnerId()); break;
                        case 10: AllBadges.NiceQuestion.CreateForQuestion(tableRepository, questionEntry.GetOwnerId(), request.QuestionId); break;
                        case 25: AllBadges.GoodQuestion.CreateForQuestion(tableRepository, questionEntry.GetOwnerId(), request.QuestionId); break;
                        case 100: AllBadges.GreatQuestion.CreateForQuestion(tableRepository, questionEntry.GetOwnerId(), request.QuestionId); break;
                    }
                }
            }

            // insert le vote
            tableRepository.InsertOrReplace(userQuestionEntry, Tables.UserQuestion);

            // badges
            if (response.VoteKind == VoteKind.Up)
                AllBadges.Supporter.CreateIfNotExist(tableRepository, userId);
            else if (response.VoteKind == VoteKind.Down)
                AllBadges.Critic.CreateIfNotExist(tableRepository, userId);

            return response;
        }
Ejemplo n.º 36
0
        public object Any(Love request)
        {
            Guid userId = UserSession.GetUserId();

            LoveResponse response = new LoveResponse
            {
                Result = ErrorCode.OK,
            };

            TableRepository tableRepository = new TableRepository();

            UserQuestionEntry userQuestionEntry = tableRepository.Get<UserQuestionEntry>(Tables.UserQuestion, request.QuestionId, userId);

            // Création d'un nouveau vote
            if (userQuestionEntry == null)
            {
                DateTime dateTime = DateTime.UtcNow;
                userQuestionEntry = new UserQuestionEntry(request.QuestionId, userId)
                {
                    Creation = dateTime,
                    Modification = dateTime
                };
            }
            else
            {
                userQuestionEntry.Modification = DateTime.UtcNow;
            }

            userQuestionEntry.Love = !userQuestionEntry.Love;

            // insert le vote
            tableRepository.InsertOrReplace(userQuestionEntry, Tables.UserQuestion);

            return response;
        }
Ejemplo n.º 37
0
        private UserCard CreateUserCard(TableRepository tableRepository, Guid creatorId)
        {
            UserEntry user = tableRepository.Get<UserEntry>(Tables.Users, creatorId.ToString())?.FirstOrDefault();

            return new UserCard
            {
                Id = creatorId,
                Username = user?.UserName
            };
        }
Ejemplo n.º 38
0
        public object Any(Answers request)
        {
            TableRepository tableRepository = new TableRepository();
            CloudTable questionTable = tableRepository.GetTable(Tables.Questions);

            Guid questionId = Guid.Parse(request.Id);

            TableQuery<QuestionEntry> questionQuery = questionTable.CreateQuery<QuestionEntry>();

            QuestionEntry questionEntry = (from k in questionQuery
                                           where k.RowKey == questionId.ToString()
                                           select k).SingleOrDefault();

            if (questionEntry == null)
                throw HttpError.NotFound("Such question do not exist");

            questionEntry.Views++;
            tableRepository.InsertOrMerge(questionEntry, Tables.Questions);

            CloudTable answerTable = tableRepository.GetTable(Tables.Answers);
            TableQuery<AnswerEntry> answerQuery = answerTable.CreateQuery<AnswerEntry>();

            AnswerEntry[] answerEntries = (from k in answerQuery
                                           where k.PartitionKey == questionId.ToString()
                                           select k).ToArray();

            UserQuestionEntry userQuestionEntry = UserSession.IsAuthenticated
                                            ? tableRepository.Get<UserQuestionEntry>(Tables.UserQuestion, questionId, UserSession.GetUserId())
                                            : null;

            HashSet<string> votesUp = new HashSet<string>(userQuestionEntry?.VotesUp?.Split('|') ?? new string[] { });
            HashSet<string> votesDown = new HashSet<string>(userQuestionEntry?.VotesDown?.Split('|') ?? new string[] { });

            Func<Guid, VoteKind> getVoteKind = ownerId =>
                                         {
                                             if (votesUp.Contains(ownerId.ToString()))
                                                 return VoteKind.Up;

                                             if (votesDown.Contains(ownerId.ToString()))
                                                 return VoteKind.Down;

                                             return VoteKind.None;
                                         };

            AnswersResponse answersResponse = new AnswersResponse
            {
                Id = questionEntry.GetId(),
                Creation = questionEntry.Creation,
                Owner = CreateUserCard(tableRepository, questionEntry.GetOwnerId()),
                Detail = questionEntry.Detail,
                Tags = questionEntry.Tags.SplitAndTrimOn(new char[] { ',' }),
                Title = questionEntry.Title,
                Views = questionEntry.Views,
                Votes = questionEntry.Votes,
                SelectedAnswer = questionEntry.SelectedAnswer,
                Answers = answerEntries.Select(k => new AnswerResult
                {
                    Owner = CreateUserCard(tableRepository, k.GetAnswerOwnerId()),
                    Creation = k.Creation,
                    Content = k.Content,
                    Votes = k.Votes,
                    VoteKind = getVoteKind(k.GetAnswerOwnerId())
                }).ToArray()
            };

            // quest user vote for this question
            answersResponse.VoteKind = getVoteKind(questionId);
            answersResponse.Love = userQuestionEntry?.Love ?? false;

            return answersResponse;
        }
Ejemplo n.º 39
0
        public object Any(Answer request)
        {
            Guid userId = UserSession.GetUserId();

            TableRepository tableRepository = new TableRepository();

            // create answers
            AnswerEntry answerEntry = tableRepository.Get<AnswerEntry>(Tables.Answers, request.QuestionId, userId);
            if (answerEntry == null)
            {
                DateTime dateTime = DateTime.UtcNow;
                answerEntry = new AnswerEntry(request.QuestionId, userId)
                {
                    Content = request.Content,
                    Creation = dateTime,
                    Modification = dateTime,
                    Votes = 0
                };

                // update the answers count
                QuestionEntry questionEntry = tableRepository.Get<QuestionEntry>(Tables.Questions, request.QuestionOwnerId, request.QuestionId);
                if (questionEntry != null)
                {
                    questionEntry.Answers++;
                    tableRepository.InsertOrMerge(questionEntry, Tables.Questions);
                }
            }
            else
            {
                // perform an edit
                answerEntry.Content = request.Content;
                answerEntry.Modification = DateTime.UtcNow;
            }

            tableRepository.InsertOrMerge(answerEntry, Tables.Answers);

            AnswerResponse response = new AnswerResponse
            {
                Result = ErrorCode.OK
            };

            return response;
        }
Ejemplo n.º 40
0
 public Table GetTable(int id)
 {
     TableRepository tableRepository = new TableRepository();
     return tableRepository.Get(id);
 }
Ejemplo n.º 41
0
        public object Any(Top request)
        {
            TableRepository tableRepository = new TableRepository();
            var questions = tableRepository.GetTable(Tables.Questions).CreateQuery<QuestionEntry>().ToArray().Take(10);

            // "No similar question found... yet !"
            return new TopResponse
            {
                Questions = questions.Select(k => new TopQuestionResponse
                {
                    Id = k.GetId(),
                    Title = k.Title,
                    Votes = k.Votes,
                    Answers = k.Answers,
                    Views = k.Views
                }).ToArray()
            };
        }
Ejemplo n.º 42
0
 public TablesController()
 {
     var db = new CartSysContext();
     repo = new TableRepository(db);
     tableService = new TableService(repo);
 }