Inheritance: System.Data.Objects.DataClasses.EntityObject
        /// <summary>
        /// Update profile of contestant
        /// </summary>
        /// <param name="profile"></param>
        public void UpdateProfile(Profile profile)
        {
            _dbContext.Profiles.Attach(_dbContext.Profiles.Single(p => p.Id == profile.Id));
            _dbContext.Profiles.ApplyCurrentValues(profile);

            _dbContext.SaveChanges();
        }
        public ActionResult Index(Profile model)
        {
            if (ContestantService.GetContestant(User.Identity.Name) != null)
            {
                return View("AlreadyRegistered");
            }

            if (ModelState.IsValid)
            {
                var date = getJoinedDate();
                if (date != null)
                {
                    model.JoinedDate = date.Value;
                    if (!string.IsNullOrEmpty(model.RegistrationPost))
                    {
                        model.RegistrationPost = GPlusUrlC14n(model.RegistrationPost);
                    }
                    ContestantService.AddContestant(new Contestant(User.Identity.Name, model));
                    return RedirectToAction("Success");
                }
            }

            ViewBag.User = GoogleUser;
            ViewBag.MinDate = MinDate;
            return View("ContestantRegistration", model);
        }
        public void TestUpdateContestant()
        {

            var gPlusId = "107711263447378891785";
            var expect = new Profile
            {
                Id = 2,
                Tagline = "ttt" + DateTime.Now.Minute,
                Interest = "iii" + DateTime.Now.Minute,
                Characteristic = "ccc" + DateTime.Now.Minute,
                RegistrationPost = "rrr" + DateTime.Now.Minute,
                ActingCute = "aaa" + DateTime.Now.Minute,
                JoinedDate = DateTime.Now
            };

            var repository = new ContestantRepository();
            repository.UpdateProfile(expect);

            var actual = repository.GetContestant(gPlusId).Profile;
            Assert.AreEqual(expect.Tagline, actual.Tagline);
            Assert.AreEqual(expect.ActingCute, actual.ActingCute);
            Assert.AreEqual(expect.Interest, actual.Interest);
            Assert.AreEqual(expect.Characteristic, actual.Characteristic);
            Assert.AreEqual(expect.RegistrationPost, actual.RegistrationPost);
            Assert.AreEqual(expect.JoinedDate, actual.JoinedDate);
        }
        internal void UpdateProfileByGoogleId(string googlePlusId, Profile profile)
        {
            var pid = _dbContext.Profiles.Single(c => c.Contestant.GooglePlusId == googlePlusId).Id;
            profile.Id = pid;
            _dbContext.Profiles.ApplyCurrentValues(profile);

            _dbContext.SaveChanges();
        }
        /// <summary>
        /// Update profile of contestant
        /// </summary>
        /// <param name="profile"></param>
        public void UpdateContestantProfile(string googlePlusId, Profile profile)
        {
            if (string.IsNullOrEmpty(googlePlusId))
            {
                throw new ArgumentNullException("GPlus Id");
            }
            if (profile == null)
            {
                throw new ArgumentNullException("contestant");
            }

            _contestantRepository.UpdateProfileByGoogleId(googlePlusId, profile);
        }
        public ActionResult Index()
        {
            if (ContestantService.GetContestant(User.Identity.Name) != null)
            {
                return View("AlreadyRegistered");
            }

            ViewBag.User = GoogleUser;
            ViewBag.MinDate = MinDate;

            var model = new Profile
            {
                Tagline = GoogleUser.TagLine
            };
            return View("ContestantRegistration", model);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Profiles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProfiles(Profile profile)
 {
     base.AddObject("Profiles", profile);
 }
 /// <summary>
 /// Create a new Profile object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="interest">Initial value of the Interest property.</param>
 /// <param name="characteristic">Initial value of the Characteristic property.</param>
 /// <param name="actingCute">Initial value of the ActingCute property.</param>
 /// <param name="tagline">Initial value of the Tagline property.</param>
 /// <param name="joinedDate">Initial value of the JoinedDate property.</param>
 public static Profile CreateProfile(global::System.Int32 id, global::System.String interest, global::System.String characteristic, global::System.String actingCute, global::System.String tagline, global::System.DateTime joinedDate)
 {
     Profile profile = new Profile();
     profile.Id = id;
     profile.Interest = interest;
     profile.Characteristic = characteristic;
     profile.ActingCute = actingCute;
     profile.Tagline = tagline;
     profile.JoinedDate = joinedDate;
     return profile;
 }
 public ActionResult Edit(Profile model)
 {
     if (ModelState.IsValid)
     {
         var date = getJoinedDate();
         if (date != null)
         {
             model.JoinedDate = date.Value;
             if (!string.IsNullOrEmpty(model.RegistrationPost))
             {
                 model.RegistrationPost = GPlusUrlC14n(model.RegistrationPost);
             }
             ContestantService.UpdateContestantProfile(User.Identity.Name, model); 
             return RedirectToAction("Success");
         }
     }
     ViewBag.User = GoogleUser;
     ViewBag.MinDate = MinDate;
     return View("ContestantRegistration", model);
 }
Exemple #10
0
 public Contestant(string googlePlusId, Profile profile)
     : this()
 {
     GooglePlusId = googlePlusId;
     Profile = profile;
 }