Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "moustafa"

actually this issue help me to fix my problem [https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1354])

but i don't what i'm doing in the previous snippet of code is right or not is there any way to exclude some properties from being mapped or updated what is the good practice for such a cases ? thank you

Hi maybe you right :D but i will try to implement it to understand exactly the idea of domain service thank you

Hi, i appreciate your help

1- i think you forgot to write down link of documentation for unit of work transaction

2- actually i tried for hours to convert _iUserAppService to a DomainService to be used in my PatientAppService but unfortunately i didn't succeeded , i'm so confused about that , i reviewed the link you provided many times but the situations is totally different when it related to UserAppService i follow the steps carefully trying to achieve it till i reach to create UserManager class which should inherit from DomainService class but as you know UserManager Class already exists and already inherits from AbpUserManager<Tenant, Role, User> class , so i tried to create another class and continue but i think i running in wrong way so can you please provide me with snippet code that help me in my case and i think you already have a fresh copy of my project files if you want to do it & test from your side

regards

sent waiting for your response

ok please provide me with your email or should i use this one <a href="mailto:[email protected]">[email protected]</a>

Hi, thank you for coming back

Register.cshtml

@model Umbrella.Web.Models.Account.RegisterViewModel
@using System.Web.Script.Serialization
@using Abp.Extensions
@using Abp.Web.Mvc.Extensions
@using Umbrella.MultiTenancy
@using Recaptcha.Web
@using Recaptcha.Web.Mvc
@section Scripts
{
    <script>
        window.passwordComplexitySetting = @(new JavaScriptSerializer().Serialize(Model.PasswordComplexitySetting).Replace("\"", ""));
    </script>
    @Html.IncludeScript("~/Views/Account/Register.js")
}
<form class="register-form" action="@Url.Action("Register")" method="post">

    <h3>@L("SignUp")</h3>

    @if (@ViewBag.ErrorMessage != null)
    {
        <div class="alert alert-danger">
            <i class="fa fa-warning"></i> @ViewBag.ErrorMessage
        </div>
    }

    @Html.AntiForgeryToken()

    @if (ViewBag.IsMultiTenancyEnabled)
    {
        if (Model.TenancyName.IsNullOrEmpty())
        {
            <p class="hint hide">
                @L("TenantInformations")
            </p>
            <div class="form-group hide">
                <label class="control-label visible-ie8 visible-ie9">@L("TenancyName")</label>
                <input class="form-control placeholder-no-fix input-ltr" type="text" placeholder="@L("TenancyName")" name="TenancyName" value="@(Model.TenancyName ?? "Default")" required maxlength="@Tenant.MaxTenancyNameLength" />
            </div>
        }
        else
        {
            <input type="hidden" name="TenancyName" value="@Model.TenancyName" />
        }
    }

    <input type="hidden" name="IsExternalLogin" value="@Model.IsExternalLogin.ToString()" />

    <p class="hint">
        @L("PersonalInformations")
    </p>
    <div class="form-group">
        <label class="control-label visible-ie8 visible-ie9">@L("QuadName")</label>
        <input class="form-control placeholder-no-fix" type="text" placeholder="@L("QuadName")" name="Name" required value="@Model.Name" maxlength="@Umbrella.UmbrellaConsts.MaxNameLength" autocomplete="off" onkeypress="return checkCharacters(event,'ar');" onpaste="return false;"/>
        @Html.ValidationMessageFor(m => m.Name, "", new { @class = "text-danger" })
    </div>
    <div class="form-group">
        <label class="control-label visible-ie8 visible-ie9">@L("Mobile")</label>
        <input class="form-control placeholder-no-fix" type="text" placeholder="@L("Mobile")" name="Mobile" required value="@Model.Mobile" maxlength="@Umbrella.UmbrellaConsts.MaxMobileLength" data-val-regex="@L("InvalidMobile")" data-val-regex-pattern="05(0|3|5|4|6|8|9)[0-9]{7}" data-val="true" autocomplete="off" onkeypress="return checkNumbers(event)" onpaste="return false;"/>
        @Html.ValidationMessageFor(m => m.Mobile, "", new { @class = "text-danger" })
    </div>
    @*<div class="form-group">
            <label class="control-label visible-ie8 visible-ie9">@L("Surname")</label>
            <input class="form-control placeholder-no-fix" type="text" placeholder="@L("Surname")" name="Surname" required value="@Model.Surname" maxlength="@Umbrella.Authorization.Users.User.MaxSurnameLength" />
        </div>*@
    <div class="form-group">
        <label class="control-label visible-ie8 visible-ie9">@L("EmailAddress")</label>
        <input class="form-control placeholder-no-fix" type="email" placeholder="@L("EmailAddress")" name="EmailAddress" value="@Model.EmailAddress" maxlength="@Umbrella.Authorization.Users.User.MaxEmailAddressLength" autocomplete="off" onkeypress="return checkEnglishAndNumbersAtSymbol(event);" onpaste="return false;" />
        @Html.ValidationMessageFor(m => m.EmailAddress, "", new { @class = "text-danger" })
    </div>

    @if (!Model.IsExternalLogin)
    {
        <p class="hint">
            @L("AccountSettings")
        </p>
        <div class="form-group">
            <label class="control-label visible-ie8 visible-ie9">@L("IdentityNumber")</label>
            <input class="form-control placeholder-no-fix input-ltr" type="text" autocomplete="off" placeholder="@L("IdentityNumber")" name="UserName" value="@Model.UserName" required maxlength="@Umbrella.UmbrellaConsts.MaxIdentityLength" data-val-regex="@L("InvalidIdentityNumber")" data-val-regex-pattern="10[0-9]{8}" data-val="true" onkeypress="return checkNumbers(event)" onpaste="return false;"/>
            @Html.ValidationMessageFor(m => m.UserName, "", new { @class = "text-danger" })
        </div>
        <div class="form-group">
            <label class="control-label visible-ie8 visible-ie9">@L("Password")</label>
            <input class="form-control placeholder-no-fix" type="password" autocomplete="off" id="RegisterPassword" placeholder="@L("Password")" name="Password" required data-val="true" onpaste="return false;"/>
            @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
        </div>
        <div class="form-group">
            <label class="control-label visible-ie8 visible-ie9">@L("PasswordRepeat")</label>
            <input class="form-control placeholder-no-fix" type="password" autocomplete="off" placeholder="@L("PasswordRepeat")" name="PasswordRepeat" required data-val="true" data-val-equalto-other="Password" data-val-equalto="@L("PasswordNotMatch")" onpaste="return false;"/>
            @Html.ValidationMessageFor(m => m.PasswordRepeat, "", new { @class = "text-danger" })
        </div>
    }

    @if (ViewBag.UseCaptcha)
    {
        <p class="hint">
            @L("Captha_Hint")
        </p>
        <div class="form-group margin-bottom-20">
            @Html.Recaptcha(theme: RecaptchaTheme.Red)
        </div>
    }

    <div class="form-actions">
        <a href="@Url.Action("Login","Account")"><button type="button" id="register-back-btn" class="btn btn-default">@L("Back")</button></a>&nbsp;
        <button type="submit" id="register-submit-btn" class="btn btn-primary uppercase">@L("Submit")</button>
    </div>
</form>

Register.js

var CurrentPage = function () {

    jQuery.validator.addMethod("customUsername", function (value, element) {
        if (value === $('input[name="EmailAddress"]').val()) {
            return true;
        }

        return !$.validator.methods.email.apply(this, arguments);
    }, abp.localization.localize("RegisterFormUserNameInvalidMessage"));

    var _passwordComplexityHelper = new app.PasswordComplexityHelper();

    var handleRegister = function () {

        $('.register-form').validate({
            errorElement: 'span', //default input error message container
            errorClass: 'help-block', // default input error message class
            focusInvalid: false, // do not focus the last invalid input
            ignore: "",
            rules: {
                PasswordRepeat: {
                    equalTo: "#RegisterPassword"
                },
                UserName: {
                    required: true,
                    customUsername: true
                }
            },

            messages: {

            },

            invalidHandler: function (event, validator) {

            },

            highlight: function (element) {
                $(element).closest('.form-group').addClass('has-error');
            },

            success: function (label) {
                label.closest('.form-group').removeClass('has-error');
                label.remove();
            },

            errorPlacement: function (error, element) {
                if (element.closest('.input-icon').size() === 1) {
                    error.insertAfter(element.closest('.input-icon'));
                } else {
                    error.insertAfter(element);
                }
            },

            submitHandler: function (form) {
                form.submit();
            }
        });

        $('.register-form input').keypress(function (e) {
            if (e.which == 13) {
                if ($('.register-form').valid()) {
                    $('.register-form').submit();
                }
                return false;
            }
        });

        var $element = $('#RegisterPassword');
        _passwordComplexityHelper.setPasswordComplexityRules($element, window.passwordComplexitySetting);
    }

    return {
        init: function () {
            handleRegister();
        }
    };

}();

Note that i'm using jquery unobtrusive validation because i need ti use regex annotation in RegisterViewModel , as jquery validation will not show up validation message if i didn't add some attributes to Password Input

RegisterViewModel

public class RegisterViewModel : IValidatableObject
    {
        /// <summary>
        /// Not required for single-tenant applications.
        /// </summary>
        [StringLength(Tenant.MaxTenancyNameLength)]
        public string TenancyName { get; set; }

        [Required]
        [StringLength(UmbrellaConsts.MaxNameLength)]
        public string Name { get; set; }

        //[Required]
        [StringLength(UmbrellaConsts.MaxNameLength)]
        public string Surname { get; set; }

        [StringLength(User.MaxUserNameLength)]
        [RegularExpression("10[0-9]{8}")]
        public string UserName { get; set; }

        //[Required]
        [EmailAddress]
        [StringLength(User.MaxEmailAddressLength)]
        public string EmailAddress { get; set; }
        [Required]
        [StringLength(User.MaxPlainPasswordLength)]
        [DisableAuditing]
        public string Password { get; set; }
        [Required]
        [StringLength(User.MaxPlainPasswordLength)]
        [DisableAuditing]
        public string PasswordRepeat { get; set; }

        public bool IsExternalLogin { get; set; }

        public PasswordComplexitySetting PasswordComplexitySetting { get; set; }

        [Required]
        [StringLength(UmbrellaConsts.MaxMobileLength)]
        [RegularExpression("05(0|3|5|4|6|8|9)[0-9]{7}")]
        public string Mobile { get; set; }
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (!UserName.IsNullOrEmpty())
            {
                if (!UserName.Equals(EmailAddress) && new ValidationHelper().IsEmail(UserName))
                {
                    yield return new ValidationResult("Username cannot be an email address unless it's same with your email address !");
                }
            }
        }

    }

by the way the same situation in reset password page but i didn't made any changes on that page , the validation show up tell me that password should contains small letter but it accept from me numbers only but if i set settings the password should contains both small and uppercase letter it works just fine Thank you for your concern

i have no errors in console window of course i did all the necessary changes in Register.cshtml and Register.js actually i working on the last version v.12.0

this object returned when execute the command "window.passwordComplexitySetting"

Object 
MaxLength:25
MinLength:6
UseLowerCaseLetters:true
UseNumbers:true
UsePunctuations:false
UseUpperCaseLetters:false
__proto__:Object

by the way these are not the values saved in my database

Object 
MaxLength:25
MinLength:8
UseLowerCaseLetters:true
UseNumbers:true
UsePunctuations:false
UseUpperCaseLetters:true
__proto__:Object

and its working just fine in reset password page and user's settings

Thank you

Thank you now it's working just fine

i'm sorry if i bothering you with my questions actually i tried the following UserManager

private readonly IRepository<User, long> _userRepository;


    public virtual async Task<User> FindByMobileAsync(string mobile)
        {
            return await _userRepository.FirstOrDefaultAsync(
                user => user.Mobile == mobile
                );
        }

i got error because _userRepository is null what i missing here ?

then what shall i do also to use L Method in usermanager ? can you please provide me a piece of code to help in my situation ? thank you

Showing 41 to 50 of 75 entries