Exemple #1
0
        public Models.Vote Create(Models.Vote entity)
        {
            try
            {
                entity = VoteDataProccessor.ValidationAndProcess(entity);

                if (((new RestfulModels.Vote()).Search(new Models.VoteSearchModel()
                {
                    ReviewId = entity.ReviewId, Creator = entity.Creator
                })).Count() > 0)
                {
                    var e = new RestfulModels.ValidationException();
                    e.ValidationErrors.Add("已经存在");

                    throw e;
                }

                DbEntities.Votes.AddObject(entity);
                DbEntities.SaveChanges();
                DbEntities.Refresh(System.Data.Objects.RefreshMode.StoreWins, entity);

                return(entity);
            }
            catch
            {
                throw;
            }
        }
Exemple #2
0
        public static IList <RestfulJsonProccessor.RestfulOption> ControlProcess(Models.Vote data, string userName)
        {
            try
            {
                if ((new Models.AccountMembershipService()).IsAdmin(userName))
                {
                    var options = new List <RestfulJsonProccessor.RestfulOption>();

                    options.Add(
                        new RestfulJsonProccessor.RestfulOption()
                    {
                        Object           = "Vote",
                        ObjectId         = data.Id,
                        ActionId         = "Delete_Vote",
                        ActionName       = "删除",
                        ActionDefinition = "删除投票",
                        ActionType       = Models.RestfulAction.Delete,
                        HttpMethod       = "DELETE",
                        Uri = Models.ApplicationConfig.Domain + "Api/Vote/" + data.Id
                    }
                        );

                    return(options);
                }
                else
                {
                    return(null);
                }
            }
            catch {
                return(null);
            }
        }
Exemple #3
0
        public async Task OnPostVoteAsync(int id)
        {
            if (_signinmanager.IsSignedIn(User))
            {
                string userID = User?.Claims?.Where(c => c.Issuer == "LOCAL AUTHORITY")?.First().Value;

                int currentVoteCount = _context
                                       .Votes
                                       .Where(u => u.UserId == userID)
                                       .Count();

                if (currentVoteCount < 10)
                {
                    Models.Vote v = new Models.Vote
                    {
                        SessionId = id,
                        UserId    = userID
                    };

                    _context.Votes.Add(v);
                    await _context.SaveChangesAsync();
                }

                await LoadData(userID);
            }
        }
Exemple #4
0
        public ActionResult Vote(VoteModel model)
        {
            if (!ModelState.IsValid)
            {
                model = initVoteModel(model.questionID);
                return(View(model));
            }
            VoteDao votedao = new VoteDao();
            //检查用户是否已经投过票了 否则在原来的基础上更改
            User     u = new UserDao().getById(model.userID);
            Question q = new QuestionDao().getById(model.questionID);

            Vote v = votedao.getByUserAndQuestion(u, q);

            if (v == null)
            {
                v = new Models.Vote();
            }
            v.queID       = new QuestionDao().getById(model.questionID);
            v.userID      = u;
            v.voteComment = model.voteComment;
            v.voteTime    = DateTime.Now;
            v.voteRecord  = model.voteRecord;
            if (v.ID != 0)
            {
                votedao.update(v);
            }
            else
            {
                votedao.add(v);
            }
            return(RedirectToAction("Index"));
        }
Exemple #5
0
 public Vote Map(Models.Vote vote)
 {
     return(new Vote(
                vote.Id,
                new UserMap().Map(vote.User),
                new RestaurantMap().Map(vote.Restaurant)
                ));
 }
Exemple #6
0
 static HomeController()
 {
     vote         = new Models.Vote();
     vote.Popular = new int[vote.Article.Count];
     for (int i = 0; i < vote.Popular.Length; i++)
     {
         vote.Popular[i] = 0;
     }
 }
Exemple #7
0
 public static ViewModel.VoteVM ToVoteVM(this Models.Vote vote)
 {
     return((vote == null) ? null : new ViewModel.VoteVM
     {
         Id = vote.Id,
         FirstCat = vote.FirstCat.ToCatVM(),
         SecondCat = vote.SecondCat.ToCatVM(),
         //WinnerCat = vote.Winner.ToCatVM(),
         //User = vote.User
     });
 }
Exemple #8
0
        public async Task OnPostRemoveAsync(int id)
        {
            if (_signinmanager.IsSignedIn(User))
            {
                string userID = User?.Claims?.Where(c => c.Issuer == "LOCAL AUTHORITY")?.First()?.Value;

                Models.Vote v = await _context.Votes.FindAsync(id, userID);

                _context.Votes.Remove(v);
                await _context.SaveChangesAsync();

                await LoadData(userID);
            }
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Vote = await _context.Votes
                   .Include(v => v.Session).FirstOrDefaultAsync(m => m.SessionId == id);

            if (Vote == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Vote = await _context.Votes.FindAsync(id);

            if (Vote != null)
            {
                _context.Votes.Remove(Vote);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Vote = await _context.Votes
                   .Include(v => v.Session).FirstOrDefaultAsync(m => m.SessionId == id);

            if (Vote == null)
            {
                return(NotFound());
            }
            ViewData["SessionId"] = new SelectList(_context.Sessions, "Id", "Description");
            return(Page());
        }
Exemple #12
0
 public static bool Pass(byte action, Models.Vote Vote, string accessor = null)
 {
     try
     {
         if (action == RestfulAction.Create)
         {
             if (!string.IsNullOrEmpty(accessor) && (new Models.AccountMembershipService()).Exist(accessor))
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else if (action == RestfulAction.Read)
         {
             return(true);
         }
         else if (action == RestfulAction.Update)
         {
             return(false);
         }
         else if (action == RestfulAction.Delete)
         {
             if (!string.IsNullOrEmpty(accessor) && accessor == Vote.Creator)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemple #13
0
        public static Models.Vote ValidationAndProcess(Models.Vote data)
        {
            try
            {
                ValidationException validationException = new ValidationException();

                try
                {
                    if (data.ReviewId == null || (data.ReviewId < 1) || (new RestfulModels.Review()).Read((int)data.ReviewId) == null)
                    {
                        validationException.ValidationErrors.Add("产品评价为空");
                    }
                }
                catch
                {
                    validationException.ValidationErrors.Add("产品评价为空");
                }

                if (data.Supportive != true)
                {
                    data.Supportive = false;
                }

                //created
                if (data.Created == null)
                {
                    data.Created = DateTime.Now;
                }

                if (validationException.ValidationErrors.Count() > 0)
                {
                    throw validationException;
                }
                else
                {
                    return(data);
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #14
0
        public Models.Vote Create(Models.Vote entity, string userName)
        {
            try
            {
                if (!VoteAccessControl.Pass(RestfulAction.Create, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

                entity.Creator = userName;
                entity.Created = DateTime.Now;

                return(RestfulVote.Create(entity));
            }
            catch
            {
                throw;
            }
        }
Exemple #15
0
        private static object DataProcess(Models.Vote data, string userName)
        {
            try
            {
                return(new
                {
                    Id = data.Id,
                    ReviewId = data.ReviewId,
                    Supportive = data.Supportive,
                    Creator = RestfulJsonProccessor.Account.MiniSingle(data.Creator),
                    Created = data.Created.ToString(),

                    Options = ControlProcess(data, userName)
                });
            }
            catch
            {
                throw;
            }
        }
Exemple #16
0
 public ActionResult Create(Models.Vote data)
 {
     try
     {
         return(Json
                (
                    new
         {
             Entity = RestfulJsonProccessor.Vote.Single(RestfulVote.Create(data, User.Identity.IsAuthenticated ? User.Identity.Name : null), User.Identity.IsAuthenticated ? User.Identity.Name : null)
         },
                    JsonRequestBehavior.AllowGet
                ));
     }
     catch (RestfulModels.NoAccessException)
     {
         Response.StatusCode = 401;
         return(null);
     }
     catch (RestfulModels.ValidationException e)
     {
         Response.StatusCode = 406;
         return(Json
                (
                    new
         {
             ValidationErrors = e
         },
                    JsonRequestBehavior.AllowGet
                ));
     }
     catch
     {
         Response.StatusCode = 500;
         return(null);
     }
 }
        protected override void Seed(MyStackOverFlow.Models.ApplicationDbContext context)
        {
            var passwordHash = new PasswordHasher();

            string password1 = passwordHash.HashPassword("1!Qwer");
            var    User1     = new Models.ApplicationUser
            {
                Id                   = "1",
                Email                = "*****@*****.**",
                EmailConfirmed       = false,
                PasswordHash         = password1,
                SecurityStamp        = Guid.NewGuid().ToString("D"),
                PhoneNumber          = null,
                PhoneNumberConfirmed = false,
                TwoFactorEnabled     = false,
                LockoutEndDateUtc    = null,
                LockoutEnabled       = false,
                AccessFailedCount    = 0,
                UserName             = "******",
                Reputation           = 180
            };


            string password2 = passwordHash.HashPassword("2!John");
            var    User2     = new Models.ApplicationUser
            {
                Id           = "2",
                UserName     = "******",
                Email        = "*****@*****.**",
                PasswordHash = password2,
                Reputation   = 150
            };


            string password3 = passwordHash.HashPassword("3!Mike");
            var    User3     = new Models.ApplicationUser
            {
                Id           = "3",
                UserName     = "******",
                Email        = "*****@*****.**",
                PasswordHash = password3,
                Reputation   = 100
            };

            context.Users.AddOrUpdate(x => x.Id, User1);
            context.Users.AddOrUpdate(x => x.Id, User2);
            context.Users.AddOrUpdate(x => x.Id, User3);

            context.SaveChanges();

            var tag1 = new Models.Tag {
                TagId = 1, Title = "MVC"
            };
            var tag2 = new Models.Tag {
                TagId = 2, Title = "C#"
            };
            var tag3 = new Models.Tag {
                TagId = 3, Title = "EF Model"
            };
            var tag4 = new Models.Tag {
                TagId = 4, Title = "Asp.net"
            };
            var tag5 = new Models.Tag {
                TagId = 5, Title = ".net Core"
            };
            var tag6 = new Models.Tag {
                TagId = 6, Title = "String"
            };

            context.Tags.AddOrUpdate(t => t.TagId, tag1);
            context.Tags.AddOrUpdate(t => t.TagId, tag2);
            context.Tags.AddOrUpdate(t => t.TagId, tag3);
            context.Tags.AddOrUpdate(t => t.TagId, tag4);
            context.Tags.AddOrUpdate(t => t.TagId, tag5);
            context.Tags.AddOrUpdate(t => t.TagId, tag6);


            var Q1 = new Models.Question
            {
                Id    = 1,
                Tilte = "Introducing FOREIGN KEY constraint 'FK_dbo.Comments_dbo.Questions_QuestionId' " +
                        "on table  may cause cycles or multiple cascade paths. in mvc ASP.net",
                Description = "ve been wrestling with this for a while and can't quite figure out what's happening. " +
                              "I have a Card entity which contains Sides (usually 2) - and both Cards and Sides have a Stage. " +
                              "I'm using EF Codefirst migrations and the migrations are failing with this error:",
                Qdate      = DateTime.Parse("2016-05-02"),
                UserId     = "1",
                QVoteCount = 45
            };

            var Q2 = new Models.Question
            {
                Id          = 2,
                Tilte       = "check which user is login asp.net mvc.",
                Description = "I want to show some div at the view only if user has logged in. " +
                              "But Request.IsAuthenticated(and User.Identity.IsAuthenticated) is always true even in the very beginning," +
                              "right after I start the website from Visual Studio.Apparently," +
                              "it gets me as the user logged in Windows(because User.Identity.Name returns my Windows login)," +
                              "but I need it to check if user has authenticated on website via FormsAuthentication.",
                Qdate      = DateTime.Parse("2016-08-15"),
                UserId     = "2",
                QVoteCount = 20
            };

            var Q3 = new Models.Question
            {
                Id    = 3,
                Tilte = "pagedList doesnt show ordered data on 2nd page mvc c# EF code first?",

                Description = "My problem is that the search string is 'lost' when I page to the second page," +
                              " so instead of a filtered set of results, I'm shown all the records.",
                Qdate      = DateTime.Parse("2017-02-21"),
                UserId     = "2",
                QVoteCount = 10
            };

            var Q4 = new Models.Question
            {
                Id    = 4,
                Tilte = "Differnce between string And String c#",

                Description = "What is the difference between String and string in C# mvc .net?",
                Qdate       = DateTime.Parse("2015-12-11"),
                UserId      = "1",
                QVoteCount  = 37
            };

            var Q5 = new Models.Question
            {
                Id          = 5,
                Tilte       = "How to properly write seed method in Entity Framework mvc?",
                Description = "ve been wrestling with this for a while and can't quite figure out what's happening. " +
                              "I have a Card entity which contains Sides (usually 2) - and both Cards and Sides have a Stage. " +
                              "I'm using EF Codefirst migrations and the migrations are failing with this error:",
                Qdate      = DateTime.Parse("2018-09-10"),
                UserId     = "3",
                QVoteCount = 61
            };


            var Q6 = new Models.Question
            {
                Id          = 6,
                Tilte       = "Displaying Multiple Image Links instead of Text in WebGrid?",
                Description = "I have a WebGrid definition and three links in a single " +
                              "column by using Html.ActionLink. But, when I do not use " +
                              "LinkText property, the applicantId property is passed as null value to the Controller.",
                Qdate      = DateTime.Parse("2018-10-13"),
                UserId     = "4",
                QVoteCount = 25
            };
            var Q7 = new Models.Question
            {
                Id          = 7,
                Tilte       = "How to speed up large data in reactjs?",
                Description = "I am trying to get million of data " +
                              "and showing the data tables. Now, I am trying to check static data instead of" +
                              "getting from database . class UL extends React.Compontent { state = { data: [],..",
                Qdate      = DateTime.Parse("2018-02-18"),
                UserId     = "2",
                QVoteCount = 21
            };
            var Q8 = new Models.Question
            {
                Id          = 8,
                Tilte       = "Android Studio, cannot see anymore warnings, errors and println in “4:Run”?",
                Description = "i cant see anymore my warning, errors and println in my console, but i need it]",
                Qdate       = DateTime.Parse("2016-01-07"),
                UserId      = "2",
                QVoteCount  = 10
            };
            var Q9 = new Models.Question
            {
                Id          = 9,
                Tilte       = "Push unique objects into array in JAVASCRIPT",
                Description = "I want to push object that only have unique id1 into array." +
                              " Example: let array = [], obj = {}, access = true if(access){ obj['id1'] = 1 obj['id2'] = 2 if(array.indexOf(obj.id1) ",
                Qdate      = DateTime.Parse("2017-02-01"),
                UserId     = "1",
                QVoteCount = 18
            };
            var Q10 = new Models.Question
            {
                Id          = 10,
                Tilte       = "Access File System of a WSL as a seperate Drive",
                Description = "I have installed Ubuntu 20.04 from Microsoft Store as " +
                              "a Windows Subsystem for Linux (WSL) and I need to access the system files of it " +
                              "from Windows Explorer and access it as a separate Partition ",
                Qdate      = DateTime.Parse("2015-02-11"),
                UserId     = "1",
                QVoteCount = 18
            };
            var Q11 = new Models.Question
            {
                Id    = 11,
                Tilte = "I have installed Ubuntu 20.04 from Microsoft Store as a Windows Subsystem for Linux (WSL)" +
                        "and I need to access the system files of it from Windows Explorer and access it as a separate Partition",
                Description = "I have a question about Kotlin error messages. Let's say I have a simple error caused by not " +
                              "closing a print statement: fun main() { println('Hello.' } and the error returned is: Hello.kt:2:54:",
                Qdate      = DateTime.Parse("2016-08-07"),
                UserId     = "1",
                QVoteCount = 18
            };


            context.Questions.AddOrUpdate(q => q.Id, Q1);
            context.Questions.AddOrUpdate(q => q.Id, Q2);
            context.Questions.AddOrUpdate(q => q.Id, Q3);
            context.Questions.AddOrUpdate(q => q.Id, Q4);
            context.Questions.AddOrUpdate(q => q.Id, Q5);

            Q1.Tag.Add(tag1);
            Q1.Tag.Add(tag2);
            Q1.Tag.Add(tag3);

            Q2.Tag.Add(tag4);
            Q2.Tag.Add(tag5);
            Q2.Tag.Add(tag6);

            Q3.Tag.Add(tag1);
            Q3.Tag.Add(tag3);
            Q3.Tag.Add(tag5);

            Q4.Tag.Add(tag1);
            Q4.Tag.Add(tag2);
            Q4.Tag.Add(tag4);

            Q5.Tag.Add(tag2);
            Q5.Tag.Add(tag3);
            Q5.Tag.Add(tag5);

            var Ans1 = new Models.Answer
            {
                Id          = 1,
                UserId      = "2",
                Description = "Owned entity types are never included by EF Core in the model by convention. You can use the " +
                              "OwnsOne method in OnModelCreating or annotate the type with OwnedAttribute (new in EF Core 2.1) " +
                              "to configure the type as an owned type in mvc",
                Ansdate      = DateTime.Parse("2016-05-08"),
                QuestionId   = 1,
                AnsVoteCount = 122
            };

            var Ans2 = new Models.Answer
            {
                Id          = 2,
                UserId      = "3",
                Description = "When using a relational database, the database provider selects a data type based on the .NET " +
                              "type of the property.It also takes into account other metadata, such as the configured maximum length, " +
                              "whether the property is part of a primary key, etc.",
                Ansdate      = DateTime.Parse("2016-05-09"),
                QuestionId   = 1,
                AnsVoteCount = 327
            };

            var Ans3 = new Models.Answer
            {
                Id          = 3,
                UserId      = "1",
                Description = "Owned entity types are never included by EF Core in the model by convention. You can use the " +
                              "OwnsOne method in OnModelCreating or annotate the type with OwnedAttribute (new in EF Core 2.1) " +
                              "to configure the type as an owned type in mvc",
                Ansdate      = DateTime.Parse("2016-08-16"),
                QuestionId   = 2,
                AnsVoteCount = 87
            };

            var Ans4 = new Models.Answer
            {
                Id          = 4,
                UserId      = "3",
                Description = "When using a relational database, the database provider selects a data type based on the .NET " +
                              "type of the property.It also takes into account other metadata, such as the configured maximum length, " +
                              "whether the property is part of a primary key, etc.",
                Ansdate    = DateTime.Parse("2016-09-01"),
                QuestionId = 2,

                AnsVoteCount = 267
            };

            var Ans5 = new Models.Answer
            {
                Id          = 5,
                UserId      = "3",
                Description = "The problem is your PagedList entry doesn't include your sort order nor your current filter.+" +
                              "In addition to adding ViewBag.CurrentSort as suggested by Vasanth," +
                              " you also need to change your PagedListPager to:",
                Ansdate      = DateTime.Parse("2017-02-22"),
                QuestionId   = 3,
                AnsVoteCount = 89
            };
            var Ans6 = new Models.Answer
            {
                Id          = 6,
                UserId      = "2",
                Description = "string is an alias in C# for System.String.So technically, " +
                              "there is no difference. It's like int vs. System.Int32.",
                Ansdate      = DateTime.Parse("2015-12-12"),
                QuestionId   = 4,
                AnsVoteCount = 101
            };

            var Ans7 = new Models.Answer
            {
                Id          = 7,
                UserId      = "2",
                Description = "Alternatively, you can use context.Database.EnsureCreated() to create a new database " +
                              "containing the seed data, for example for a test database or when using the in-memory provider or any " +
                              "non-relation database. Note that if the database already exists, EnsureCreated() will neither update the " +
                              "schema nor seed data in the database. " +
                              "For relational databases you shouldn't call EnsureCreated() if you plan to use Migrations.",
                Ansdate      = DateTime.Parse("2015-12-12"),
                QuestionId   = 5,
                AnsVoteCount = 332
            };

            context.Answers.AddOrUpdate(A => A.Id, Ans1);
            context.Answers.AddOrUpdate(A => A.Id, Ans2);
            context.Answers.AddOrUpdate(A => A.Id, Ans3);
            context.Answers.AddOrUpdate(A => A.Id, Ans4);
            context.Answers.AddOrUpdate(A => A.Id, Ans5);
            context.Answers.AddOrUpdate(A => A.Id, Ans6);
            context.Answers.AddOrUpdate(A => A.Id, Ans7);

            var QCom1 = new Models.QComment
            {
                Id          = 1,
                QuestionId  = 1,
                UserId      = "2",
                Comdate     = DateTime.Parse("2017-02-21"),
                Description = "This Question can be found in another place"
            };
            var QCom2 = new Models.QComment
            {
                Id          = 2,
                QuestionId  = 1,
                UserId      = "3",
                Comdate     = DateTime.Parse("2017-08-12"),
                Description = "This is the 2nd Comment on Question 1"
            };

            var QCom3 = new Models.QComment
            {
                Id          = 3,
                QuestionId  = 2,
                UserId      = "3",
                Comdate     = DateTime.Parse("2016-09-18"),
                Description = "This is the 1st Comment on Question 2"
            };
            var QCom4 = new Models.QComment
            {
                Id          = 4,
                QuestionId  = 3,
                UserId      = "1",
                Comdate     = DateTime.Parse("2017-09-03"),
                Description = "This is the Ist Comment on Question 3"
            };


            var QCom5 = new Models.QComment
            {
                Id          = 5,
                QuestionId  = 5,
                UserId      = "3",
                Comdate     = DateTime.Parse("2018-08-12"),
                Description = "This is the 1st Comment on Question 5"
            };


            context.QComments.AddOrUpdate(QC => QC.Id, QCom1);
            context.QComments.AddOrUpdate(QC => QC.Id, QCom2);
            context.QComments.AddOrUpdate(QC => QC.Id, QCom3);
            context.QComments.AddOrUpdate(QC => QC.Id, QCom4);
            context.QComments.AddOrUpdate(QC => QC.Id, QCom5);

            var Acom1 = new Models.AComment
            {
                Id          = 1,
                AnswerId    = 1,
                UserId      = "1",
                Comdate     = DateTime.Parse("2018-08-13"),
                Description = "Found this answer very informative"
            };
            var Acom2 = new Models.AComment
            {
                Id          = 2,
                AnswerId    = 2,
                UserId      = "1",
                Description = "This is the Comment on the given answer",
                Comdate     = DateTime.Parse("2019-06-17"),
            };
            var Acom3 = new Models.AComment
            {
                Id          = 3,
                AnswerId    = 2,
                UserId      = "1",
                Comdate     = DateTime.Parse("2019-03-31"),
                Description = "This is the Comment on the given answer"
            };
            var Acom4 = new Models.AComment
            {
                Id          = 4,
                AnswerId    = 3,
                UserId      = "1",
                Comdate     = DateTime.Parse("2019-07-08"),
                Description = "That works"
            };
            var Acom5 = new Models.AComment
            {
                Id          = 5,
                AnswerId    = 4,
                UserId      = "2",
                Comdate     = DateTime.Parse("2020-01-12"),
                Description = "Aah... Doesn't help"
            };

            var Acom6 = new Models.AComment
            {
                Id          = 6,
                AnswerId    = 5,
                UserId      = "1",
                Comdate     = DateTime.Parse("2020-02-23"),
                Description = "This is the comment on answer 5"
            };

            context.AComments.AddOrUpdate(AC => AC.Id, Acom1);
            context.AComments.AddOrUpdate(AC => AC.Id, Acom2);
            context.AComments.AddOrUpdate(AC => AC.Id, Acom3);
            context.AComments.AddOrUpdate(AC => AC.Id, Acom4);
            context.AComments.AddOrUpdate(AC => AC.Id, Acom5);
            context.AComments.AddOrUpdate(AC => AC.Id, Acom6);

            var vote1 = new Models.Vote
            {
                Id = 1, QuestionId = 1, UpVote = true
            };

            var vote2 = new Models.Vote
            {
                Id         = 2,
                QuestionId = 2,
                DownVote   = true
            };

            var vote3 = new Models.Vote
            {
                Id         = 3,
                QuestionId = 2,
                UpVote     = true
            };
            var vote4 = new Models.Vote
            {
                Id         = 4,
                QuestionId = 2,
                UpVote     = false
            };

            context.Votes.AddOrUpdate(v => v.Id, vote1);
            context.Votes.AddOrUpdate(v => v.Id, vote2);
            context.Votes.AddOrUpdate(v => v.Id, vote3);
            context.Votes.AddOrUpdate(v => v.Id, vote4);
            context.SaveChanges();



            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
        }
Exemple #18
0
 public static object Single(Models.Vote data, string userName)
 {
     return(DataProcess(data, userName));
 }
 public void Update(UpdateVoteInput input)
 {
     Models.Vote output = Mapper.Map <UpdateVoteInput, Models.Vote>(input);
     _voteManager.Update(output);
 }
 public async Task Create(CreateVoteInput input)
 {
     Models.Vote output = Mapper.Map <CreateVoteInput, Models.Vote>(input);
     await _voteManager.Create(output);
 }