Beispiel #1
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            var repository = new FriendsRepository();

            try {
                FriendViewModel fvm = new FriendViewModel();

                fvm.Id        = Int32.Parse(collection["Id"]);
                fvm.FristName = collection["FristName"];
                fvm.LastName  = collection["LastName"];
                fvm.BirthDate = DateTime.Parse(collection["BirthDate"]);
                repository.UpdateFriend(fvm);
                return(RedirectToAction("Index"));
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                return(View());
            }
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                var tempId        = int.Parse(collection["FriendId"].ToString());
                var tempName      = collection["FriendName"].ToString();
                var tempLastName  = collection["FriendLastName"].ToString();
                var tempBirthDate = DateTime.Parse(collection["FriendBirthDate"].ToString());

                Friend friend = new Friend(tempId, tempName, tempLastName, tempBirthDate, 0);

                friend.FriendDaysToBirthDate = friend.GetDaysToBirthDate();

                repository.UpdateFriend(friend);

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                throw e;
            }
        }