コード例 #1
0
 /// <summary>
 /// Add with to database.
 /// </summary>
 ///
 /// <param name="model">
 /// ViewModel containing wish data model.
 /// </param>
 public void Add(AddWishViewModel model)
 {
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         db.Wishes.Add(new Wish
         {
             UserId            = UserProfile.Current.UserId,
             ReceiverFirstName = model.ReceiverFirstName,
             ReceiverLastName  = model.ReceiverLastName,
             Story             = model.Story,
             Testimony         = model.Testimony,
             Name        = String.Format("{0} {1}", UserProfile.Current.FirstName, UserProfile.Current.LastName),
             Cost        = model.Cost,
             DateCreated = DateTime.UtcNow,
             DateUpdated = DateTime.UtcNow,
         });
         db.SaveChanges();
     }
 }
コード例 #2
0
        public ActionResult CreateWish(AddWishViewModel model)
        {
            _adapter.Add(model);

            return(RedirectToAction("Index", "Home"));
        }