Beispiel #1
0
        private void OnSaveProfile(object sender, EventArgs e)
        {
            var user = UsersService.Add(Mapper.Map <EmployerModel>((EmployerViewModel)BindingContext));

            App.User = user;
            Navigation.PopAsync();
        }
Beispiel #2
0
        private void OnSignUp(object sender, EventArgs e)
        {
            var user = (UserModel)BindingContext;

            if (String.IsNullOrEmpty(user.Email))
            {
                ShowError("Вкажіть емейл");
                return;
            }
            if (String.IsNullOrEmpty(user.Password))
            {
                ShowError("Вкажіть пароль");
                return;
            }
            if (TypePicker.Items[TypePicker.SelectedIndex] == "Employer")
            {
                var employer = Mapper.Map <EmployerModel>(user);
                var result   = UsersService.Add(employer);
                App.User = (EmployerModel)result;
            }
            else
            {
                var employee = Mapper.Map <EmployeeModel>(user);
                var result   = UsersService.Add(employee);
                App.User = (EmployeeModel)result;
            }

            App.Current.MainPage = new NavigationPage(new MainPage(true)
            {
                Title = "Редагувати"
            });
        }
 public void Save()
 {
     if (CheckData())
     {
         UsersService userService = new UsersService();
         if ((this.DataContext as UserEntity).Id == -1)
         {
             if (userService.Add(this.DataContext as UserEntity) == 0)
             {
                 MessageBox.Show("Utente Salvato!");
                 this.DataContext = new UserEntity();
             }
             else
             {
                 MessageBox.Show("Errore durante il salvataggio!");
             }
         }
         else
         {
             if (userService.Update(this.DataContext as UserEntity) == 0)
             {
                 MessageBox.Show("Utente Salvato!");
             }
             else
             {
                 MessageBox.Show("Errore durante il salvataggio!");
             }
         }
     }
 }
Beispiel #4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.Users u = new Model.Users
            {
                Users_Account  = this.txtEmail.Text,
                Users_Password = MD5Helper.Md5(this.txtPassword.Text),
                Users_NickName = this.txtNickName.Text,
                Users_Photo    = upFileName(this.FileUpload1, "../../upload/users/"),
                Users_RolesId  = Guid.Parse(this.ddlRolesId.SelectedValue)
            };
            var       res = usersSvc.Add(u);
            ReturnMsg rm  = res > 0
                ? new ReturnMsg()
            {
                Code    = StatusCode.OK,
                Message = "新增用户信息成功",
                Data    = null
            }
                : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "新增用户信息失败",
                Data    = null
            };

            Session["Msg"] = rm; //用于传递执行信息的
            Response.Redirect("Users_List.aspx");
        }
Beispiel #5
0
        public ActionResult Add()
        {
            var userList = UsersService.Add(new Model.Users {
                Address = "海信大道", LoginId = "lizj", Number = "123456789", Name = "CL", Password = "******", UserId = 1236
            });

            return(Json(userList, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(Users users)
        {
            if (ModelState.IsValid)
            {
                service.Add(users);
                return(RedirectToAction("Index"));
            }

            return(View(users));
        }
        // GET: /TOnboarding/ProcessCode
        public ActionResult ProcessCode(string code, string error, string error_description, string resource, string state)
        {
            // Is this a response to a request we generated? Let's see if the state is carrying an ID we previously saved
            // ---if we don't, return an error
            if (TenantsService.GetAll().FirstOrDefault(a => a.IssValue == state) == null)
            {
                // TODO: prettify
                return(View("Error"));
            }
            else
            {
                // ---if the response is indeed from a request we generated
                // ------get a token for the Graph, that will provide us with information abut the caller
                ClientCredential credential = new ClientCredential(ConfigurationManager.AppSettings["ida:ClientID"],
                                                                   ConfigurationManager.AppSettings["ida:Password"]);
                AuthenticationContext authContext = new AuthenticationContext("https://login.windows.net/common/");
                AuthenticationResult  result      = authContext.AcquireTokenByAuthorizationCode(
                    code, new Uri(Request.Url.GetLeftPart(UriPartial.Path)), credential);

                var myTenant = TenantsService.GetAll().FirstOrDefault(a => a.IssValue == state);
                CurrentUser.TenantId = result.TenantId;
                // if this was an admin consent, save the tenant
                if (myTenant.AdminConsented)
                {
                    // ------read the tenantID out of the Graph token and use it to create the issuer string
                    string issuer = String.Format("https://sts.windows.net/{0}/", result.TenantId);
                    myTenant.IssValue = issuer;
                }
                else
                //otherwise, remove the temporary entry and save just the user
                {
                    if (UsersService.GetAll().FirstOrDefault(a => (a.UPN == result.UserInfo.DisplayableId) && (a.TenantID == result.TenantId)) == null)
                    {
                        UsersService.Add(new User {
                            UPN = result.UserInfo.DisplayableId, TenantID = result.TenantId
                        });
                    }
                    TenantsService.Delete(myTenant);
                }

                // remove older, unclaimed entries
                DateTime tenMinsAgo = DateTime.Now.Subtract(new TimeSpan(0, 10, 0)); // workaround for Linq to entities
                var      garbage    = TenantsService.GetAll().Where(a => (!a.IssValue.StartsWith("https") && (a.Created < tenMinsAgo)));
                foreach (Tenant t in garbage)
                {
                    TenantsService.Delete(t);
                }

                TenantsService.Commit();
                // ------return a view claiming success, inviting the user to sign in
                return(View());
            }
        }
        public void AddShould_ReturnValue()
        {
            // Arrange
            var  userService = new UsersService(userRepoMock.Object, contextMock.Object);
            User user        = new User();

            // Arrange
            contextMock.Setup(x => x.Commit()).Returns(1);
            var result = userService.Add(user);

            // Assert
            Assert.IsInstanceOf(typeof(int), result);
        }
Beispiel #9
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Users model)
        {
            //首先判断用户名是否已存在
            Users entity = dal.GetModel(model.UserName);

            if (entity != null)
            {
                return(-1);    //用户名已存在
            }
            else
            {
                return(dal.Add(model));
            }
        }
Beispiel #10
0
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="userModel"></param>
 /// <returns></returns>
 public bool AddUser(UsersModel userModel)
 {
     try
     {
         userModel.UserID    = Guid.NewGuid();
         userModel.CreatedOn = DateTime.Now;
         userModel.CreatedBy = CommonMess.PersentUser.UserName;
         return(_userSvc.Add(userModel));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #11
0
 public async Task Post()
 {
     try
     {
         Service.Add(new Models.Users()
         {
             Id       = Guid.NewGuid().ToString(),
             Nick     = Request.Form["nick"],
             Password = Request.Form["pwd"],
             UserName = Request.Form["account"]
         });
         await Json(new { result = true });
     }
     catch (Exception ex)
     {
         await Status(StatusCode.UNKNOWERROR, ex.Message);
     }
 }
        private async void OnSaveProfile(object sender, EventArgs e)
        {
            var userViewModel = (UserViewModel)BindingContext;
            var user          = Mapper.Map <UserModel>(userViewModel);

            user.TrackedDays = new List <TrackedDayModel>()
            {
                new TrackedDayModel()
                {
                    Id   = 0,
                    Goal = user.Goal,
                    Date = DateTime.Now
                }
            };
            user.Photo = "https://media.licdn.com/dms/image/C5603AQGAzsg5qZRzzg/profile-displayphoto-shrink_200_200/0?e=1562803200&v=beta&t=WVi627qWCw58aEtQ2DI-jirm3WVdjQWLQCEvy4eOV1A";
            App.User   = user;
            UsersService.Add(user);
            await Navigation.PushAsync(new MainPage());
        }
        // POST: api/Users
        public IHttpActionResult Post([FromBody] UserDTO value)
        {
            try
            {
                if (value == null)
                {
                    return(BadRequest());
                }
                else
                {
                    var usersService = new UsersService();

                    return(Ok(usersService.Add(value)));
                }
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }
Beispiel #14
0
        /// <summary>
        /// 注册按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            //新增的时候要求传递内容为对象(user)对象,需要创建对应的对象出来
            Users user = new Users()
            {
                //trim() 去除空格
                Name     = this.txtName.Text.Trim(),
                Birthday = this.txtBirthday.Text.Trim(),
                Sex      = this.RdMan.Checked ? "男" : "女", //三元表达式 ? 代表真的  : 代表假的
                Pid      = int.Parse(this.ddlProvince.SelectedValue),
                Cid      = int.Parse(this.ddlCity.SelectedValue),
                Aid      = int.Parse(this.ddlArea.SelectedValue),
                Addresss = this.txtAddress.Text
            };
            int rs = us.Add(user);

            if (rs > 0)
            {
                Response.Write("<script>alert('注册成功!')</script>");
            }
        }
Beispiel #15
0
        private async void Bot_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
        {
            // Обрабатываем только текстовые сообщения.
            if (e.Message.Type != Telegram.Bot.Types.Enums.MessageType.Text)
            {
                return;
            }

            // Проверим от кого поступила команда.

            long chatId = e.Message.Chat.Id;

            try
            {
                var user = _users.Where(u => u.TelegramUserId == e.Message.From.Id).FirstOrDefault();

                if (user == null)
                {
                    user = new User
                    {
                        ChatId         = chatId,
                        TelegramUserId = e.Message.From.Id
                    };

                    _users.Add(user);
                }

                // Обрабатываем команду.
                await ProcessCommand(user, e.Message.Text);
            }
            catch (Exception exc)
            {
                var message = $"Ошибка обработки команды. {exc.Message}";

                await _bot.SendTextMessageAsync(chatId, message);

                logger.Error(message);
            }
        }
        public async Task <IActionResult> OnPostSubmit()
        {
            if (!ModelState.IsValid)
            {
                LoadRoles(RoleName);

                return(Page());
            }

            if (Input.Roles.Contains(Enumerations.RolesEnum.Admins.ToString()) && !User.IsInRole(Enumerations.RolesEnum.Admins.ToString()))
            {
                ModelState.AddModelError("", UsersResources.msg_YouMustBeAdminToCreateAdmins);
                return(Page());
            }


            var result = await UsersService.Add(new ReturnResult <UserViewModel>() { Value = Input });

            ModelState.Merge(result);

            if (!ModelState.IsValid)
            {
                LoadRoles(RoleName);
                return(Page());
            }


            if (string.IsNullOrEmpty(ReturnUrl))
            {
                ShowMessage(CoreEnumerations.MessageTypes.info, UsersResources.UserCreatedSuccessfully);
                return(RedirectToPage("/Users/Index", new { area = "UserManagementAdmin" }));
            }
            else
            {
                ShowMessage(CoreEnumerations.MessageTypes.info, UsersResources.UserCreatedSuccessfullyStepOne);
                return(Redirect($"{ReturnUrl}/{result.Value.Id}"));
            }
        }
        protected void btnSumbit_OnClick(object sender, EventArgs e)
        {
            Model.Users u = new Model.Users
            {
                Email      = this.Email.Text,
                Password   = this.Password.Text,
                NickName   = this.NickName.Text,
                RolesId    = int.Parse(this.RolesList.SelectedValue),
                Photo      = upload.UpFileName(FileUpload1, "../../upload/users/"),
                CreateTime = DateTime.Now
            };

            int rs = usersSvc.Add(u);

            if (rs > 0)
            {
                Response.Write("<script>alert('添加成功');location.href='UsersList.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');location.href='AddUsers.aspx'</script>");
            }
        }
Beispiel #18
0
        protected void btnKaydet_Click(object sender, EventArgs e)
        {
            try
            {
                Users user        = new Users();
                Users CurrentUser = (Users)Session["user"];

                user.UserName  = txtUserName.Text;
                user.FirstName = txtFirstName.Text;
                user.LastName  = txtLastName.Text;
                user.Email     = txtMail.Text;
                user.Facebook  = txtFacebook.Text;
                user.Twitter   = txtTwitter.Text;
                user.Instagram = txtInstagram.Text;
                user.Youtube   = txtYoutube.Text;
                user.Linkedin  = txtLinkedin.Text;
                user.UserImage = lblInfo.Text;
                user.UserRole  = drpAdminRole.SelectedItem.Text;
                if (int.Parse(RadioButtonList1.SelectedItem.Value) == 1)
                {
                    user.IsActive = true;
                }
                else
                {
                    user.IsActive = false;
                }

                if (txtPassword.Text == txtPasswordAgain.Text)
                {
                    user.Password = txtPassword.Text;
                }
                else
                {
                    Uyari("Girdiğiniz şifreler aynı değil!", false);
                }

                user.CreatedBy   = CurrentUser.ID;
                user.CreatedDate = DateTime.Now;

                _userService.Add(user);

                clear();
                Butonvisible(true);
                panelVisible(true, true, false, false);
                Uyari("Kayıt işlemi başarıyla gerçekleşti", true);
            }
            catch (Exception)
            {
                if (txtUserName.Text.Length > 50)
                {
                    Uyari("Kullanıcı adı 50 karakterden daha uzun girilemez!", false);
                }
                else if (txtFirstName.Text.Length > 30)
                {
                    Uyari("İsim 30 karakterden daha uzun girilemez!", false);
                }
                else if (txtLastName.Text.Length > 40)
                {
                    Uyari("Soyisim 40 karakterden daha uzun girilemez!", false);
                }
                else
                {
                    Uyari("Kayıt işlemi sırasında bir hata oluştu", false);
                }
            }
        }
Beispiel #19
0
 public static void Add(int ID, string Name, string Psw)
 {
     UsersService.Add(ID, Name, Psw);
 }
Beispiel #20
0
 public void Add(Users users)
 {
     usersService.Add(users);
 }