Example #1
0
        public async Task Test_for_AddUserProfileAsync()
        {
            User user = new User()
            {
                Id            = 1,
                UserName      = "******",
                FirstName     = "Abi",
                LastName      = "B",
                ContactNumber = 99037464774,
                Experience    = 2,
            };

            userService.Setup(repos => repos.AddProfile(user)).ReturnsAsync(user);
            var addedProfile = await _userServices.AddProfile(user);

            var getprofile = await _userServices.GetProfile(user.Id);

            //Assert
            Assert.Equal(getprofile, addedProfile);
            Assert.Equal(user, addedProfile);
        }
Example #2
0
        public string AddUser(string nombre, string usuario, string codigo, string passw, string search)
        {
            ResponseModel        resp;
            UserFormModel        model = new UserFormModel();
            List <UserFormModel> users = new List <UserFormModel>();

            resp = new ResponseModel();
            //RELLENAR VALUES CASE FAIL...
            //model.Supervisores = _userservices.GetSupervisores();
            //model.Codigos = _userservices.GetCodigos();
            //model.PhoneProveedores = _userservices.GetProveedores();

            //<!===========================================>
            //     CREAR LOGIN
            //<!===========================================>
            model.resp     = resp;
            model.UserName = usuario.ToLower();
            model.Codigo   = codigo.ToUpper();
            model.Nombre   = nombre;
            model.Password = passw;

            model.resp    = _userservices.AddLogin(model);
            model.LoginId = model.resp.identity;

            //trer resp.identity (loginId in case exist)
            // en case
            //model.LoginId = resp.identity;

            //<!===========================================>
            //     CREAR PROFILE
            //<!===========================================>

            model.resp = _userservices.AddProfile(model);
            // trer resp.identity (loginId in case exist)
            // en case
            model.ProfileId = resp.identity;

            if (!model.resp.response)
            {
                //ViewBag.typeMsg = "wn";
                //ViewBag.message = model.resp.message;
                return(model.resp.message);
            }

            model.ProfileId = model.resp.identity;

            //<!===========================================>
            //     CREAR USER
            //<!===========================================>


            AppUser user = new AppUser
            {
                UserName  = model.UserName,
                Email     = model.UserName + "@elaviso.com",
                ProfileId = model.ProfileId,
                LoginId   = model.LoginId
            };

            IdentityResult result = CreateUser(user, model.Password).Result;

            if (result.Succeeded)
            {
                model.Id = user.Id;
                users.Add(model);
                string sdata = "ok| Usuario Creado (" + model.LoginId.ToString() + ")" + "^";
                sdata += Objeto.SerializarLista(users, '|', '~', false);
                return(sdata);
            }
            else
            {
                return("er| " + resp.message + "| Users Mgr ");
            }
        }