Exemple #1
0
        private bool DoUpdateUser(UserAccountViewModel model)
        {
            var svc     = new UserAppSvcGeneric();
            var updated = svc.Update(model.GetEntity());

            return(updated != null);
        }
        public IHttpActionResult Patch(UserViewModel model)
        {
            if (!model.id.HasValue || model.id.Value < 0)
            {
                return(BadRequest());
            }

            var svc      = new UserAppSvcGeneric();
            var toUpdate = svc.Get(model.id.Value);

            if (toUpdate == null)
            {
                return(NotFound());
            }

            try {
                toUpdate.Name = model.name;
                var result = svc.Update(toUpdate);

                return(Ok(result));
            }
            catch (Exception ex) {
                return(InternalServerError(ex));
            }
        }
Exemple #3
0
        public void UpdateTest()
        {
            var svc      = new UserAppSvcGeneric();
            var toUpdate = new User {
                Id = 2, Name = "New Name For Common"
            };
            var updated = svc.Update(toUpdate);

            Assert.IsNotNull(updated);
            Assert.AreEqual(toUpdate.Id, updated.Id);
            Assert.AreEqual(toUpdate.Name, updated.Name);
        }