Beispiel #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Votings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToVotings(Voting voting)
 {
     base.AddObject("Votings", voting);
 }
Beispiel #2
0
 /// <summary>
 /// Create a new Voting object.
 /// </summary>
 /// <param name="votingId">Initial value of the VotingId property.</param>
 /// <param name="dishId">Initial value of the DishId property.</param>
 /// <param name="votedOn">Initial value of the VotedOn property.</param>
 /// <param name="votedBy">Initial value of the VotedBy property.</param>
 public static Voting CreateVoting(global::System.Int32 votingId, global::System.Int32 dishId, global::System.DateTime votedOn, global::System.Int32 votedBy)
 {
     Voting voting = new Voting();
     voting.VotingId = votingId;
     voting.DishId = dishId;
     voting.VotedOn = votedOn;
     voting.VotedBy = votedBy;
     return voting;
 }
        public ActionResult MyVotes(FormCollection values)
        {
            var selectedDishes = new List<string>();

            for (int i = 0; i < values.Count; i++)
            {
                var dishId = Convert.ToInt32(values[i]);
                var dish = db.Dishes.Single(j => j.DishId == dishId);
                var voting = new Voting() { DishId = dishId, VotedOn = DateTime.Now , VotedBy= CurrentUserId};
                db.Votings.AddObject(voting);
            }

            var reward = new Reward()
            {
                RewardCreatedAt = DateTime.Now,
                RewardDescription = "Voting",
                Amount = 30,
                UserId = CurrentUserId,
                RewardTypeId = (int)RewardType.Voting
            };
            db.Rewards.AddObject(reward);

            db.SaveChanges();
            return RedirectToAction("MyVotes");
        }