Ejemplo n.º 1
0
        public ActionResult Edit(FormCollection model)
        {
            int    id    = Convert.ToInt32(model["FriendId"]);
            string name  = model["FriendName"].ToString();
            string place = model["Place"].ToString();

            //FriendModel entry = dbContext.Friends.Where<FriendModel>(friend => friend.FriendID.Equals(id)).First();
            var entity = entities.GetFriendById(id);

            if (entity != null)
            {
                entity.FriendName = name;
                entity.Place      = place;

                entities.UpdateFriend(entity);
                //TryUpdateModel(entity, new string[] { "FriendName", "Place" }, model.ToValueProvider());
                //dbContext.Entry(entry).CurrentValues.SetValues()
                //dbContext.Entry(entity).State = EntityState.Modified;
                //dbContext.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        [HttpPost]// POST api/<controller>
        public void Post([FromBody] FriendModel model)
        {
            var entity = _mapper.Map <FriendModel, Friend>(model);

            _dbContext.UpdateFriend(entity);
        }