Beispiel #1
0
        private async void btnSnimi_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                AdministratorUpdateRequest request = new AdministratorUpdateRequest
                {
                    Email    = txtEmail.Text,
                    GradId   = (cmbGrad.SelectedItem as Grad).Id,
                    Ime      = txtIme.Text,
                    Prezime  = txtPrezime.Text,
                    Telefon  = txtTelefon.Text,
                    Username = txtUsername.Text
                };
                if (!string.IsNullOrWhiteSpace(txtPassword.Text))
                {
                    request.Password             = txtPassword.Text;
                    request.PasswordConfirmation = txtPasswordConfirmation.Text;
                }
                else
                {
                    request.Password             = null;
                    request.PasswordConfirmation = null;
                }

                var result = await _administratorService.Update <Administrator>(administrator.Id, request);


                if (result != null)
                {
                    MessageBox.Show(Properties.Resources.UspjesnaAkcija, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
 /// <summary>
 /// 转换为参数
 /// </summary>
 /// <param name="request">请求</param>
 public static UserParameter ToParameter(this AdministratorUpdateRequest request)
 {
     if (request == null)
     {
         throw new Warning("请求参数不能为空");
     }
     return(new UserParameter
     {
         Nickname = request.Nickname,
         Gender = request.Gender,
         Enabled = request.Enabled.SafeValue(),
         Id = request.Id.ToGuid()
     });
 }
        public async Task <IActionResult> Save(AdministratorVM model)
        {
            var request = new AdministratorUpdateRequest()
            {
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Email     = model.Email,
                Username  = model.Username
            };

            try
            {
                await _eventiApi.UpdateAdministratorAsync(model.ID, request);
            }
            catch
            {
            }

            return(Redirect("AdminProfile?id=" + model.ID));
        }
Beispiel #4
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="request">请求</param>
        public async Task UpdateAsync(AdministratorUpdateRequest request)
        {
            await AdministratorManager.UpdateAsync(request.ToParameter());

            await UnitOfWork.CommitAsync();
        }
Beispiel #5
0
        public async Task <IActionResult> UpdateAsync([FromBody] AdministratorUpdateRequest request)
        {
            await AdministratorService.UpdateAsync(request);

            return(Success());
        }