Esempio n. 1
0
        private bool DoCreateUser(UserAccountViewModel model)
        {
            var svc     = new UserAppSvcGeneric();
            var created = svc.Create(model.GetEntity());

            return(created.Id > 0);
        }
Esempio n. 2
0
        public IHttpActionResult Post(UserViewModel model)
        {
            if (string.IsNullOrEmpty(model.login) ||
                string.IsNullOrEmpty(model.name) ||
                string.IsNullOrEmpty(model.email) ||
                string.IsNullOrEmpty(model.password))
            {
                return(BadRequest());
            }

            try
            {
                var svc      = new UserAppSvcGeneric();
                var toCreate = model.GetUser();
                var result   = svc.Create(toCreate);
                if (result.Id > 0)
                {
                    return(Ok(result));
                }

                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 3
0
        public void CreateTest()
        {
            var usr = new User
            {
                Email        = "*****@*****.**",
                IsActive     = true,
                Login        = "******",
                Name         = "New User",
                RegisterDate = DateTime.Now,
                Password     = "******",
                UserTypeId   = 1
            };
            var svc = new UserAppSvcGeneric();
            var res = svc.Create(usr);

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Id > 0);
        }