public void AddAdminUser(string email, string username, string password)
		{
			try
			{
				using (IUnitOfWork unitOfWork = _context.CreateUnitOfWork())
				{
					var user = new User();
					user.Email = email;
					user.Username = username;
					user.SetPassword(password);
					user.IsAdmin = true;
					user.IsEditor = true;
					user.IsActivated = true;

					var entity = new UserEntity();
					ToEntity.FromUser(user, entity);

					unitOfWork.Add(entity);
					unitOfWork.SaveChanges();
				}
			}
			catch (Exception e)
			{
				throw new DatabaseException(e, "Install failed: unable to create the admin user using '{0}' - {1}", ConnectionString, e.Message);
			}
		}
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserEntity user = new UserEntity();
            user.UserID = "Test";
            Session["User"] = user;

            List<MarkEntity> L=StaticFactory.markDB.GetTopListByCreateDate(10);
            for (int i = 0; i < L.Count; i++) {
                HtmlGenericControl div = new HtmlGenericControl("div");

                HtmlGenericControl spanA = new HtmlGenericControl("span");
                spanA.Attributes.Add("class", "icon-map-marker");

                HtmlGenericControl spanB = new HtmlGenericControl("span");
                spanB.Attributes.Add("style", "padding-left:20px;");
                spanB.InnerText= L[i].MarkName;

                div.Controls.Add(spanA);
                div.Controls.Add(spanB);

                div.Attributes.Add("zoomLevel", L[i].zoomLevel.ToString());
                div.Attributes.Add("title", L[i].MarkCommentA);

                extPanel.Controls.Add(div);
            }
        }
Example #3
0
        public List<ApplicationEntity> GetAppplicationForUser(UserEntity user)
        {
            using (IUnitOfWork uow = _UnitFactory.GetUnit(this))
            {
                uow.BeginTransaction();
                List<ApplicationEntity> applications;
                if (UserProfileContext.Current.User.IsAdmin)
                {
                    applications = uow.Query<ApplicationEntity>().ToList();
                }
                else
                {
                    List<Guid> appLinks = uow
                        .Query<AppUserRoleEntity>()
                        .Where(x => x.UserId == UserProfileContext.Current.User.Id)
                        .Select(x => x.ApplicationId)
                        .ToList();

                    applications = uow
                        .Query<ApplicationEntity>()
                        .Where(x => appLinks.Contains(x.IdApplication))
                        .ToList();
                }
                return applications;
            }
        }
Example #4
0
        public bool AssignRoleToUser(ApplicationEntity application, UserEntity user, RolesEntity role)
        {
            try
            {
                using (IUnitOfWork uow = _UnitFactory.GetUnit(this))
                {
                    uow.BeginTransaction();
                    if (!uow.Query<AppUserRoleEntity>().Any(x => x.ApplicationId.Equals(application.IdApplication) && x.RoleId.Equals(role.Id) && x.UserId.Equals(user.Id)))
                    {
                        AppUserRoleEntity app = new AppUserRoleEntity();
                        app.ApplicationId = app.ApplicationId;
                        app.RoleId = role.Id;
                        app.UserId = user.Id;
                        uow.SaveOrUpdate(app);

                        uow.Commit();
                        return true;
                    }

                }
            }
            catch (Exception err)
            {
                //TODO:Add log here
                return false;
            }
            return true;
        }
Example #5
0
		public void fromuser_shouldfillcorrectproperties()
		{
			// Arrange
			User user = new User();
			user.Id = Guid.NewGuid();
			user.ActivationKey = "key";
			user.Email = "email";
			user.Firstname = "firstname";
			user.Id = Guid.NewGuid();
			user.IsActivated = true;
			user.IsAdmin = true;
			user.IsEditor = true;
			user.Lastname = "lastname";
			user.SetPassword("pwd");
			user.PasswordResetKey = "resetkey";
			user.Salt = "salt";

			UserEntity entity = new UserEntity();

			// Act
			ToEntity.FromUser(user, entity);

			// Assert
			Assert.That(entity.Id, Is.Not.EqualTo(user.Id));  // the id isn't copied from the page
			Assert.That(entity.ActivationKey, Is.EqualTo(user.ActivationKey));
			Assert.That(entity.Email, Is.EqualTo(user.Email));
			Assert.That(entity.Firstname, Is.EqualTo(user.Firstname));
			Assert.That(entity.IsActivated, Is.EqualTo(user.IsActivated));
			Assert.That(entity.IsAdmin, Is.EqualTo(user.IsAdmin));
			Assert.That(entity.IsEditor, Is.EqualTo(user.IsEditor));
			Assert.That(entity.Lastname, Is.EqualTo(user.Lastname));
			Assert.That(entity.Password, Is.EqualTo(user.Password));
			Assert.That(entity.Salt, Is.EqualTo(user.Salt));
		}
        public void Can_save_userRepository()
        {
            var username = Any.Name("user");
            var user = new UserEntity
            {
                Id = Guid.NewGuid(),
                Username = username,
                Email = Any.Email(username)
            };

            var repo = new RepositoryEntity()
            {
                Id = Guid.NewGuid(),
                Challenge = Any.Name(),
                Name = Any.Name(),
                UserId = user.Id
            };
            user.Repositories.Add(repo);

            _users.Save(user);

            var loadedUser = _users.Get(user.Id);
            Assert.NotEmpty(loadedUser.Repositories);
            var loadedRepo = loadedUser.Repositories[0];
            Assert.Equal(repo.Name, loadedRepo.Name);
        }
Example #7
0
        public bool Delete(UserEntity user)
        {
            bool result = true;
            try
            {
                using (IUnitOfWork uow = _UnitFactory.GetUnit(this))
                {
                    uow.BeginTransaction();
                    List<AppUserRoleEntity> entity = uow.Query<AppUserRoleEntity>().Where(x => x.UserId.Equals(user.Id)).ToList();
                    foreach (AppUserRoleEntity e in entity)
                    {
                        uow.Delete(e);
                    }

                    uow.Delete(user);

                    uow.Commit();
                }
            }
            catch (Exception e)
            {
                result = false;
            }

            return result;
        }
Example #8
0
		public void ToUser_ShouldFillCorrectProperties()
		{
			// Arrange
			UserEntity entity = new UserEntity();
			//entity.Id = Guid.NewGuid(); // can't be tested
			entity.ActivationKey = "key";
			entity.Email = "email";
			entity.Firstname = "firstname";
			entity.IsActivated = true;
			entity.IsAdmin = true;
			entity.IsEditor = true;
			entity.Lastname = "lastname";
			entity.PasswordResetKey = "resetkey";
			entity.Password = "******";
			entity.Salt = "salt";

			// Act
			User user = FromEntity.ToUser(entity);

			// Assert
			Assert.That(user.Id, Is.EqualTo(entity.Id));
			Assert.That(user.ActivationKey, Is.EqualTo(entity.ActivationKey));
			Assert.That(user.Email, Is.EqualTo(entity.Email));
			Assert.That(user.Firstname, Is.EqualTo(entity.Firstname));
			Assert.That(user.IsActivated, Is.EqualTo(entity.IsActivated));
			Assert.That(user.IsAdmin, Is.EqualTo(entity.IsAdmin));
			Assert.That(user.IsEditor, Is.EqualTo(entity.IsEditor));
			Assert.That(user.Lastname, Is.EqualTo(entity.Lastname));
			Assert.That(user.PasswordResetKey, Is.EqualTo(entity.PasswordResetKey));
			Assert.That(user.Password, Is.EqualTo(entity.Password));
			Assert.That(user.Salt, Is.EqualTo(entity.Salt));
		}
    protected void btnRegistry_Click(object sender, EventArgs e)
    {
        UserEntity oUser = new UserEntity();
        string password = INVI.INVILibrary.INVISecurity.MD5(txtPassword.Text);
        oUser.iGroupID = Convert.ToInt32(ddlDoituong.SelectedValue);
        oUser.sEmail = txtEmail.Text;
        oUser.sIP = Request.ServerVariables["REMOTE_ADDR"].Trim();
        oUser.sPassword = password;
        oUser.sUsername = txtUsername.Text;
        oUser.bActive = false;
        oUser.tLastVisit = DateTime.Now;
        try
        {
            if (UserBRL.getByUserName(txtUsername.Text) != null)
            {
                litThongtin.Text = "<b>Tài khoản này đã tồn tại</b>, xin nhập tài khoản khác.";
                return;
            }
            int FK_iUserID = UserBRL.Add(oUser);
            if (FK_iUserID>0)
                litThongtin.Text = "<b>Đăng ký thành công.</b>Các thông tin của bạn sẽ được gửi đến Quản trị để kiểm duyệt. Kết quả sẽ được gửi đến email mà bạn đã khai báo";
        }
        catch
        {

        }
        finally
        {

        }
    }
Example #10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 public User(UserEntity entity)
 {
     this._entity = entity;
     this.MembershipID = new long();
     this.Attributes = new Collection<UserAttributeEntity>();
     this.Histories = new Collection<UserHistoryEntity>();
 }
        public void TestAdd()
        {
            try
            {
                var userEntiry = new UserEntity()
                    {
                        Password = "******",
                        CreatedAt = DateTime.UtcNow,
                        UserName = "******",
                        Emails = new List<string>()
                            {
                                "*****@*****.**",
                                "*****@*****.**"
                            },
                        Options = new Dictionary<string, string>()
                            {
                                {"city", "Zhuhai"},
                                {"language", "cn"}
                            }
                    };

                var userRepo = new UserRepository();
                var task = userRepo.Add(userEntiry);
                task.Wait();

                Assert.IsNotNull(userEntiry.Id);
                Assert.IsFalse(string.IsNullOrWhiteSpace(task.Result));
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
            
        }
Example #12
0
 public static void HandleEntityError(UserEntity entity, string errorText, Exception ex)
 {
     long errorID = Append(errorText, entity, ex);
     if (entity.IsAlive)
     {
         entity.SetError(errorText, errorID);
     }
 }
Example #13
0
        public static UserEntity CreateUser()
        {
            var user = new UserEntity {
                UserName = CreateRandomString(10)
            };

            return user;
        }
Example #14
0
 public List<AppUserRoleEntity> GetApplicationRolesForUser(UserEntity userEntity)
 {
     using (IUnitOfWork uow = _UnitFactory.GetUnit(this))
     {
         uow.BeginTransaction();
         return uow.Query<AppUserRoleEntity>().Where(c => c.UserId.Equals( userEntity.Id)).ToList();
     }
 }
Example #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string userName = Request.Form["username"].ToString();
        string userPassword = Request.Form["userpass"].ToString();
        string userNickName = Request.Form["usernickname"].ToString();
        string userImage = "user.gif";
        string userEmail = Request.Form["useremail"].ToString();
        string userFrom = Request.Form["userfrom"] ?? "sjapp";
        string userWorkDay = Request.Form["userworkday"].ToString();
        string userMoney = Request.Form["usermoney"] ?? "0";
        string categoryRate = Request.Form["categoryrate"] ?? "90";

        if (userFrom.Length > 5)
        {
            userFrom = userFrom.Replace("_", "");
            userFrom = userFrom.Insert(5, "_");
        }

        UserEntity user = new UserEntity();
        user.UserName = userName;
        user.UserPassword = userPassword;
        user.UserNickName = userNickName;
        user.UserImage = userImage;
        user.UserPhone = "";
        user.UserEmail = userEmail;
        user.UserTheme = "main";
        user.UserFrom = userFrom;
        user.UserWorkDay = userWorkDay;
        user.UserMoney = Double.Parse(userMoney);
        user.CategoryRate = Double.Parse(categoryRate);

        string result = "{";

        bool repeat = UserAccess.CheckUserRepeat(userName);
        if (repeat)
        {
            result += "\"result\":\"2\"";
        }
        else
        {
            int userId = 0;
            bool success = UserAccess.InsertUser(user, out userId);
            if (success)
            {
                result += "\"result\":\"1\"";
            }
            else
            {
                result += "\"result\":\"0\"";
            }
        }

        result += "}";

        Response.Write(result);
        Response.End();
    }
    private static UserEntity ConvertToUserEntity(DataRow dr)
    {
        UserEntity user = new UserEntity();
        user.UserID = Convert.ToString(dr["UserID"]).Trim();
        user.UserName = Convert.ToString(dr["UserName"]).Trim();
        user.UserRoleID = Convert.ToString(dr["UserRoleID"]).Trim();
        user.BelongShopID = Convert.ToInt32(dr["ShopID"]);
        user.UserState = Convert.ToInt32(dr["UserState"]);

        return user;
    }
 public OperationResult modifyAccount(String requestID, UserEntity userEntity, DateTime timeStamp)
 {
     String ErrorMsg = "";
     OperationResult Result = new OperationResult();
     Result.requestID = requestID;
     Result.returnFlag = !m_Business.SaveAccount(userEntity, out ErrorMsg);
     Result.returnMsg = ErrorMsg;
     Result.returnCode = "0";
     if (Result.returnFlag) Result.returnCode = "1";
     return Result;
 }
 public OperationResult searchAccount(String requestID, UserEntity userEntity, DateTime timeStamp)
 {
     //String ErrorMsg = "";
     OperationResult Result = new OperationResult();
     //Result.requestID = requestID;
     //Result.returnFlag = !m_Business.DeleteAccount(userId, out ErrorMsg);
     //Result.returnMsg = ErrorMsg;
     //Result.returnCode = "0";
     //if (Result.returnFlag) Result.returnCode = "1";
     return Result;
 }
 public UserInfoControlHost(UserEntity user) :base ( new UserInfoControl(user ))
 {
     _user = user;
     this.AutoSize = false;
     this.UserInfoControl.CloseClick +=new EventHandler(UserInfoControl_CloseClick);
     this.UserInfoControl.UserClick += new EventHandler<LoginEventArgs>(UserInfoControl_UserClick);
     this.UserInfoControl.DownItem += new EventHandler<LoginEventArgs>(UserInfoControl_DownItem);
     this.UserInfoControl.UpItem += new EventHandler<LoginEventArgs>(UserInfoControl_UpItem);
     this.UserInfoControl.ResetControlBackColor += new EventHandler(UserInfoControl_ResetBackColor);
     this.KeyDown += new KeyEventHandler(UserInfoControlHost_KeyDown);            
 }
    public static void AddUser(UserEntity user)
    {
        Database db = DatabaseFactory.CreateDatabase();
        DbCommand dbCommand = db.GetStoredProcCommand("_business_CreateShopUser");

        db.AddInParameter(dbCommand, "@UserID", DbType.String, user.UserID);
        db.AddInParameter(dbCommand, "@UserRoleID", DbType.String, user.UserRoleID);
        db.AddInParameter(dbCommand, "@ShopID", DbType.Int32, user.BelongShopID);
        db.AddInParameter(dbCommand, "@UserName", DbType.String, user.UserName);
        db.AddInParameter(dbCommand, "@UserState", DbType.String, user.UserState);
        db.ExecuteNonQuery(dbCommand);
    }
Example #21
0
 protected string UpdateUserInfo(UserEntity user)
 {
     bool success = UserAccess.UpdateUser(user);
     if (success)
     {
         return "\"result\":\"1\"";
     }
     else
     {
         return "\"result\":\"0\"";
     }
 }
Example #22
0
        public async Task<IdentityResult> Create(string userName, string password)
        {
            var user = new UserEntity()
            {
                UserName = userName
            };

            var userManager = new DemoAppUserManager(new DemoAppUserStore());
            var result = await userManager.CreateAsync(user, password);

            return result;
        }
 public static UserModel CreateFromEntity(UserEntity u)
 {
     return new UserModel
     {
         UserId = u.UserId,
         FirstName = u.FirstName,
         LastName = u.LastName,
         Email = u.Email,
         PhoneNumber = u.PhoneNumber,
         UserStatus = u.UserStatus,
         Password = u.Password,
     };
 }
Example #24
0
        static void Main(string[] args)
        {
            var user = new UserEntity { Birthdate = DateTime.Parse("1/1/1970"), Gender= Gender.Male, FullName = "First Last", Phones = new string[] {"123","456"} };

            Console.WriteLine("user data:");

            var propertyinfos = user.GetType().GetProperties();
            foreach (var propinfo in propertyinfos)
            {
                Console.WriteLine(propinfo.Name + ": " + propinfo.GetValue(user, null));

            }

            var fieldinfo = user.GetType().GetFields();
            foreach (var propinfo in fieldinfo)
            {
                Console.WriteLine(propinfo.Name + ": " + propinfo.GetValue(user));

            }

            Console.WriteLine("Template parsing and execution:");

            string template =
@"Template
Gender: $user.Gender
FullName: $user.FullName
Birthdate: $user.Birthdate
Age: $user.Age

Phones:
#if ($user.Phones.Length > 0)
#printphones($user.Phones)
#end

#macro (printphones $phones)
#set( $no=1)
#foreach ($ph in $phones)
Phone $no: $ph
#set( $no = $no + 1)
#end
#end


";

            Dictionary<string, object> dict = new Dictionary<string, object>();
            dict["user"] = user;
            Console.WriteLine(TemplateEngine.Process(dict, template));


        }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (btnOK.Text.CompareTo(Resources.language.them) == 0)
        {
            textBox_enordis(true);
            textBox_setText("");
            btnOK.Text = Resources.language.luu;
            btnOK.CommandName = "Add";
        }
        else
        {
            Page.Validate("vgUser");
            if (Page.IsValid)
            {
                int Result = 0;
                try
                {
                    UserEntity oUser = new UserEntity();
                    oUser.iGroupID = 3;
                    oUser.sEmail = txtEmail.Text;
                    oUser.sIP = txtIP.Text;
                    oUser.sUsername = txtUsername.Text;
                    if (btnOK.CommandName.CompareTo("Edit") == 0)
                    {
                        oUser.iUserID = Convert.ToInt32(btnOK.CommandArgument);
                        UserEntity obj = UserBRL.GetOne(oUser.iUserID);
                        oUser.sPassword = txtPassword.Text.Trim() == "" ? obj.sPassword : INVI.INVILibrary.INVISecurity.MD5(txtPassword.Text);
                        UserBRL.Edit(oUser);
                        lblThongbao.Text = Resources.language.capnhapthanhcong;
                        textBox_enordis(false);

                    }
                    else
                    {
                        if (txtPassword.Text.Trim() == "")
                            throw new Exception("Chưa nhập password");
                        oUser.sPassword = INVI.INVILibrary.INVISecurity.MD5(txtPassword.Text);
                        Result = UserBRL.Add(oUser);
                    }
                    if (Result > 0) lblThongbao.Text = Resources.language.taikhoannguoidungduocthemmoi;

                    Response.Redirect(Request.Url.ToString());
                }
                catch (Exception ex)
                {
                    lblThongbao.Text = ex.Message;
                }
            }
        }
    }
Example #26
0
 public static void FromUser(User user, UserEntity entity)
 {
     entity.ActivationKey = user.ActivationKey;
     entity.Email = user.Email;
     entity.Firstname = user.Firstname;
     entity.IsActivated = user.IsActivated;
     entity.IsAdmin = user.IsAdmin;
     entity.IsEditor = user.IsEditor;
     entity.Lastname = user.Lastname;
     entity.Password = user.Password;
     entity.PasswordResetKey = user.PasswordResetKey;
     entity.Salt = user.Salt;
     entity.Username = user.Username;
 }
Example #27
0
        public UserInfoControl( UserEntity user )
        {
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
            this.UpdateStyles();

            InitializeComponent();

            _user = user;
            string username = _user.UserName.Length > 15 ? _user.UserName.Substring(0, 15) : _user.UserName;
            lblName.Text = username;
            string userid = _user.UserCode.Length > 15 ? _user.UserCode.Substring(0, 15) : _user.UserCode;
            lblUserID.Text = userid;
            tcPicture1.Image = _user.Photo;
          
        }
        public void AddNewUserToDatabase()
        {
            var user = new UserEntity
            {
                FirstName = "Petter",
                LastName = "Petter",
                DateOfBirth = DateTime.Now
            };

            using (var db = new MuscleTherapyContext())
            {
                db.Users.Add(user);
                db.SaveChanges();
            }
        }
Example #29
0
 /// <summary>
 /// Page_Load
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (UserOperation.CheckLoged(Session) == false)
     {
        SmallScript.goRedirect(Response,Session,"请登录后再浏览本页","/Login.aspx");
     }
     string id = Request.QueryString["id"].ToString();
     try
     {
         codeEntity = CodeOperation.GetCode(int.Parse(id));
         langEntity = LangOperation.GetLang(codeEntity.Lid);
         userEntity = UserOperation.GetUser(codeEntity.Uid);
         /*Pre += "<pre style=\"margin:auto;\" class=\"brush: " + langEntity.BrushAliases + ";toolbar: false;\">";*/
         Pre += File.ReadAllText(Server.MapPath(AppConfiger.GetProjectsDir(Server) + codeEntity.Path), System.Text.Encoding.GetEncoding("GBK"));
         //取出相关的注释
         List<NoteEntity> assnotes = CodeOperation.GetAssNotes(codeEntity.Id);
         //对注释进行分组
         List<int> index = new List<int>();
         List<int> indexCount = new List<int>();
         foreach (NoteEntity ne in assnotes)
         {
             if (!index.Contains(ne.StartLine))
             {
                 index.Add(ne.StartLine);
                 indexCount.Add(1);
             }
             else
             {
                 int myindex = 0;
                 while (index[myindex] != ne.StartLine)
                 {
                     myindex++;
                 }
                 indexCount[myindex]++;
             }
         }
         //编译成js支持的数组格式
         jsaLineNum = complieArray(index);
         jsaLineCount = complieArray(indexCount);
         /* Pre += "</pre>";*/
         if (index.Count == 0)
         {
             jsaLineNum = "[]";
             jsaLineCount = "[]";
         }
     }
     catch { }
 }
        public void Can_load_user_by_case_insensitive_username()
        {
            var username = Any.Name("user");
            var user = new UserEntity
            {
                Id = Guid.NewGuid(),
                Username = username,
                Email = Any.Email(username)
            };
            _users.Save(user);

            var gotUserByName = _users.Get(user.Username.ToUpperInvariant());
            Assert.NotNull(gotUserByName);
            Assert.Equal(user.Id, gotUserByName.Id);
            Assert.Equal(user.Email, gotUserByName.Email);
        }
Example #31
0
        /// <summary>
        /// 获得指定模块或者编号的单据号(直接使用)
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="moduleId">模块ID</param>
        /// <param name="enCode">模板编码</param>
        /// <returns>单据号</returns>
        public string SetBillCode(string userId, string moduleId, string enCode, IRepository db = null)
        {
            IRepository dbc = null;

            if (db == null)
            {
                dbc = new RepositoryFactory().BaseRepository();
            }
            else
            {
                dbc = db;
            }
            UserEntity     userEntity     = db.FindEntity <UserEntity>(userId);
            CodeRuleEntity coderuleentity = db.FindEntity <CodeRuleEntity>(t => t.ModuleId == moduleId || t.EnCode == enCode);
            //判断种子是否已经产生,如果没有产生种子先插入一条初始种子
            CodeRuleSeedEntity initSeed = db.FindEntity <CodeRuleSeedEntity>(t => t.RuleId == coderuleentity.RuleId);

            if (initSeed == null)
            {
                initSeed = new CodeRuleSeedEntity();
                initSeed.Create();
                initSeed.SeedValue  = 1;
                initSeed.RuleId     = coderuleentity.RuleId;
                initSeed.CreateDate = null;
                //db.Insert<CodeRuleSeedEntity>(initSeed);
            }
            //获得模板ID
            string billCode     = "";    //单据号
            string nextBillCode = "";    //单据号
            bool   isOutTime    = false; //是否已过期

            if (coderuleentity != null)
            {
                try
                {
                    int nowSerious = 0;
                    //取得流水号种子
                    List <CodeRuleSeedEntity> codeRuleSeedlist = db.IQueryable <CodeRuleSeedEntity>(t => t.RuleId == coderuleentity.RuleId).ToList();
                    //取得最大种子
                    CodeRuleSeedEntity maxSeed = db.FindEntity <CodeRuleSeedEntity>(t => t.UserId == null);
                    #region 处理隔天流水号归0
                    //首先确定最大种子是否是隔天未归0的
                    if ((maxSeed.ModifyDate).ToDateString() != DateTime.Now.ToString("yyyy-MM-dd"))
                    {
                        isOutTime          = true;
                        maxSeed.SeedValue  = 1;
                        maxSeed.ModifyDate = DateTime.Now;
                    }
                    #endregion
                    if (maxSeed == null)
                    {
                        maxSeed = initSeed;
                    }
                    List <CodeRuleFormatEntity> codeRuleFormatList = coderuleentity.RuleFormatJson.ToList <CodeRuleFormatEntity>();
                    foreach (CodeRuleFormatEntity codeRuleFormatEntity in codeRuleFormatList)
                    {
                        switch (codeRuleFormatEntity.ItemType.ToString())
                        {
                        //自定义项
                        case "0":
                            billCode     = billCode + codeRuleFormatEntity.FormatStr;
                            nextBillCode = nextBillCode + codeRuleFormatEntity.FormatStr;
                            break;

                        //日期
                        case "1":
                            //日期字符串类型
                            billCode     = billCode + DateTime.Now.ToString(codeRuleFormatEntity.FormatStr.Replace("m", "M"));
                            nextBillCode = nextBillCode + DateTime.Now.ToString(codeRuleFormatEntity.FormatStr.Replace("m", "M"));

                            break;

                        //流水号
                        case "2":
                            //查找当前用户是否已有之前未用掉的种子
                            CodeRuleSeedEntity codeRuleSeedEntity = codeRuleSeedlist.Find(t => t.UserId == userId && t.RuleId == coderuleentity.RuleId);
                            //删除已过期的用户未用掉的种子
                            if (codeRuleSeedEntity != null && isOutTime)
                            {
                                db.Delete <CodeRuleSeedEntity>(codeRuleSeedEntity);
                                codeRuleSeedEntity = null;
                            }
                            //如果没有就取当前最大的种子
                            if (codeRuleSeedEntity == null)
                            {
                                //取得系统最大的种子
                                int maxSerious = (int)maxSeed.SeedValue;
                                nowSerious         = maxSerious;
                                codeRuleSeedEntity = new CodeRuleSeedEntity();
                                codeRuleSeedEntity.Create();
                                codeRuleSeedEntity.SeedValue = maxSerious;
                                codeRuleSeedEntity.UserId    = userId;
                                codeRuleSeedEntity.RuleId    = coderuleentity.RuleId;
                                //db.Insert<CodeRuleSeedEntity>(codeRuleSeedEntity);
                                //处理种子更新
                                maxSeed.SeedValue += 1;
                                if (maxSeed.CreateDate != null)
                                {
                                    db.Update <CodeRuleSeedEntity>(maxSeed);
                                }
                                else
                                {
                                    maxSeed.CreateDate = DateTime.Now;
                                    db.Insert <CodeRuleSeedEntity>(maxSeed);
                                }
                            }
                            else
                            {
                                nowSerious = (int)codeRuleSeedEntity.SeedValue;
                            }
                            string seriousStr     = new string('0', (int)(codeRuleFormatEntity.FormatStr.Length - nowSerious.ToString().Length)) + nowSerious.ToString();
                            string NextSeriousStr = new string('0', (int)(codeRuleFormatEntity.FormatStr.Length - nowSerious.ToString().Length)) + maxSeed.SeedValue.ToString();
                            billCode     = billCode + seriousStr;
                            nextBillCode = nextBillCode + NextSeriousStr;

                            break;

                        //部门
                        case "3":
                            DepartmentEntity departmentEntity = db.FindEntity <DepartmentEntity>(userEntity.DepartmentId);
                            if (codeRuleFormatEntity.FormatStr == "code")
                            {
                                billCode     = billCode + departmentEntity.EnCode;
                                nextBillCode = nextBillCode + departmentEntity.EnCode;
                            }
                            else
                            {
                                billCode     = billCode + departmentEntity.FullName;
                                nextBillCode = nextBillCode + departmentEntity.FullName;
                            }
                            break;

                        //公司
                        case "4":
                            OrganizeEntity organizeEntity = db.FindEntity <OrganizeEntity>(userEntity.OrganizeId);
                            if (codeRuleFormatEntity.FormatStr == "code")
                            {
                                billCode     = billCode + organizeEntity.EnCode;
                                nextBillCode = nextBillCode + organizeEntity.EnCode;
                            }
                            else
                            {
                                billCode     = billCode + organizeEntity.FullName;
                                nextBillCode = nextBillCode + organizeEntity.FullName;
                            }
                            break;

                        //用户
                        case "5":
                            if (codeRuleFormatEntity.FormatStr == "code")
                            {
                                billCode     = billCode + userEntity.EnCode;
                                nextBillCode = nextBillCode + userEntity.EnCode;
                            }
                            else
                            {
                                billCode     = billCode + userEntity.Account;
                                nextBillCode = nextBillCode + userEntity.Account;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    coderuleentity.CurrentNumber = nextBillCode;
                    db.Update <CodeRuleEntity>(coderuleentity);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(billCode);
        }
Example #32
0
        /// <summary>
        /// Add New User
        /// </summary>
        /// <param name="userAddInputDTO"></param>
        /// <returns></returns>
        public async Task <UserOutoutDTO> AddNewUser(UserAddInputDTO userAddInputDTO, int userId)
        {
            UserEntity newUser           = this.mapper.Map <UserEntity>(userAddInputDTO);
            bool       hasAccessToCreate = true;
            UserEntity loggedInUser      = await this.userRepository.GetUser(userId);

            byte[] passwordHash, passwordSalt;
            this.authService.CreatePasswordHash(newUser.EmailAddress, out passwordHash, out passwordSalt);
            newUser.passwordSalt = passwordSalt;
            newUser.passwordHash = passwordHash;

            if (loggedInUser.Role == Roles.BusinessUser)
            {
                UserEntity parent = await this.userRepository.GetUser(loggedInUser.ParentUserId);

                if (parent.AddedUsers + 1 > parent.MaxUsers)
                {
                    throw new ApplicationException("Business cannot add more users");
                }
                // Update user added users
                parent.AddedUsers = parent.AddedUsers + 1;
                await this.userRepository.UpdateUser(parent);

                UserAccessEntity userAccess = await this.userAccessRepository.GetUserAccess(userId);

                hasAccessToCreate    = userAccess != null ? userAccess.Delete : false;
                newUser.ParentUserId = loggedInUser.ParentUserId;
            }

            if (loggedInUser.Role == Roles.Business)
            {
                newUser.ParentUserId = loggedInUser.UserId;
                if (loggedInUser.AddedUsers + 1 > loggedInUser.MaxUsers)
                {
                    throw new ApplicationException("Business cannot add more users");
                }
            }

            if (hasAccessToCreate)
            {
                UserEntity updatedUser = await this.userRepository.AddUser(newUser);

                if (!updatedUser.EmailVerified)
                {
                    await this.accountService.SendVerificationEmail(updatedUser.EmailAddress);
                }

                if (loggedInUser.Role == Roles.Business)
                {
                    // Update user added users
                    loggedInUser.AddedUsers = loggedInUser.AddedUsers + 1;
                    await this.userRepository.UpdateUser(loggedInUser);
                }

                return(this.mapper.Map <UserOutoutDTO>(updatedUser));
            }
            else
            {
                throw new UnauthorizedAccessException("User don't have access to perform the add user operation");
            }
        }
Example #33
0
        /// <summary>
        /// Get User info
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task <UserOutoutDTO> GetUserInfo(int userId)
        {
            UserEntity user = await this.userRepository.GetUser(userId);

            return(this.mapper.Map <UserOutoutDTO>(user));
        }
Example #34
0
 public void FinishTest(UserEntity user)
 {
     usersTestsRepository.FinishTest(user.ToDalUser());
     uow.Commit();
 }
Example #35
0
        /// <summary>
        /// 判断登录状态
        /// </summary>
        /// <param name="token">登录票据</param>
        /// <param name="loginMark">登录设备标识</param>
        /// <returns>-1未登录,1登录成功,0登录过期</returns>
        public OperatorResult IsOnLine(string token, string loginMark)
        {
            OperatorResult operatorResult = new OperatorResult();

            operatorResult.stateCode = -1; // -1未登录,1登录成功,0登录过期
            try
            {
                if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(loginMark))
                {
                    return(operatorResult);
                }
                Operator operatorInfo = redisCache.Read <Operator>(cacheKeyOperator + loginMark, CacheId.loginInfo);
                if (operatorInfo != null && operatorInfo.token == token)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - operatorInfo.logTime);
                    if (span.TotalHours >= 12)// 登录操作过12小时移除
                    {
                        operatorResult.stateCode = 0;
                        Dictionary <string, string> tokenMarkList = redisCache.Read <Dictionary <string, string> >(cacheKeyToken + operatorInfo.account, CacheId.loginInfo);
                        tokenMarkList.Remove(loginMark);
                        redisCache.Write <Dictionary <string, string> >(cacheKeyToken + operatorInfo.account, tokenMarkList, CacheId.loginInfo);
                        redisCache.Remove(cacheKeyOperator + loginMark, CacheId.loginInfo);
                    }
                    else
                    {
                        UserInfo userInfo = new UserInfo();
                        userInfo.appId     = operatorInfo.appId;
                        userInfo.logTime   = operatorInfo.logTime;
                        userInfo.iPAddress = operatorInfo.iPAddress;
                        userInfo.browser   = operatorInfo.browser;
                        userInfo.loginMark = operatorInfo.loginMark;
                        userInfo.token     = operatorInfo.token;
                        userInfo.account   = operatorInfo.account;

                        UserEntity userEntity = userIBLL.GetEntityByAccount(operatorInfo.account);
                        if (userEntity != null)
                        {
                            userInfo.userId       = userEntity.F_UserId;
                            userInfo.enCode       = userEntity.F_EnCode;
                            userInfo.password     = userEntity.F_Password;
                            userInfo.secretkey    = userEntity.F_Secretkey;
                            userInfo.realName     = userEntity.F_RealName;
                            userInfo.nickName     = userEntity.F_NickName;
                            userInfo.headIcon     = userEntity.F_HeadIcon;
                            userInfo.gender       = userEntity.F_Gender;
                            userInfo.mobile       = userEntity.F_Mobile;
                            userInfo.telephone    = userEntity.F_Telephone;
                            userInfo.email        = userEntity.F_Email;
                            userInfo.oICQ         = userEntity.F_OICQ;
                            userInfo.weChat       = userEntity.F_WeChat;
                            userInfo.companyId    = userEntity.F_CompanyId;
                            userInfo.departmentId = userEntity.F_DepartmentId;
                            userInfo.openId       = userEntity.F_OpenId;
                            userInfo.isSystem     = userEntity.F_SecurityLevel == 1 ? true : false;

                            userInfo.roleIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 1);
                            userInfo.postIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 2);

                            userInfo.companyIds    = companyIBLL.GetSubNodes(userEntity.F_CompanyId);
                            userInfo.departmentIds = departmentIBLL.GetSubNodes(userEntity.F_CompanyId, userEntity.F_DepartmentId);

                            if (HttpContext.Current != null)
                            {
                                HttpContext.Current.Items.Add("LoginUserInfo", userInfo);
                            }
                            operatorResult.userInfo  = userInfo;
                            operatorResult.stateCode = 1;
                        }
                        else
                        {
                            operatorResult.stateCode = 0;
                        }
                    }
                }
                return(operatorResult);
            }
            catch (Exception)
            {
                return(operatorResult);
            }
        }
Example #36
0
        public static void MapUserEntityToIntegrationInfoUser(this IntegrationInfoUser integrationInfoUser, UserEntity userEntity)
        {
            integrationInfoUser.MapUserEntityToBaseUser(userEntity);
            List <ChatIntegration> integrations = userEntity.ChatIntegrations?.Select(x => x.MapDerivedChatIntegration()).ToList();

            integrationInfoUser.IntegrationsDetails = integrations;
        }
        public async Task <bool> UpdateSummonerRequestsAsync(UserEntity user, SummonerRequestView view)
        {
            var seasonInfo = await _seasonInfoRepository.GetCurrentSeasonAsync();

            SetIsSubToElements(view);
            var summoners      = (await _summonerInfoRepository.GetAllSummonersAsync()).ToDictionary(x => x.Id, x => x);
            var summonerEntity = summoners.First(x => x.Value.UserId == user.Id);

            summoners.Remove(summonerEntity.Key);

            var requestedSummonerEntities = (await _requestedSummonerRepository.ReadAllForSummonerAsync(summonerEntity.Key, seasonInfo.Id)).ToList();

            //pulled from db
            var kvp = new Dictionary <string, SummonerRequestEntity>();

            foreach (var requestEntity in requestedSummonerEntities)
            {
                if (summoners.TryGetValue(requestEntity.SummonerRequestedId, out var summoner))
                {
                    kvp.TryAdd(summoner.SummonerName, requestEntity);
                }
            }

            var createList = new List <SummonerRequestEntity>();
            var updateList = new List <SummonerRequestEntity>();
            var deleteList = new List <SummonerRequestEntity>();

            //new list
            foreach (var requestedSummoner in view.RequestedSummoners)
            {
                //skip these
                if (requestedSummoner.SummonerName == null || requestedSummoner.SummonerName == DefaultText)
                {
                    continue;
                }
                //insert
                if (!kvp.TryGetValue(requestedSummoner.SummonerName, out var oldSummonerRequest))
                {
                    var newEntity = new SummonerRequestEntity
                    {
                        Id                  = Guid.NewGuid(),
                        SummonerId          = summonerEntity.Key,
                        SummonerRequestedId = summoners.First(x => x.Value.SummonerName == requestedSummoner.SummonerName).Key,
                        IsSub               = requestedSummoner.IsSub,
                        SeasonInfoId        = seasonInfo.Id
                    };
                    createList.Add(newEntity);
                }
                //update
                else
                {
                    oldSummonerRequest.SummonerRequestedId =
                        summoners.First(x => x.Value.SummonerName == requestedSummoner.SummonerName).Key;
                    oldSummonerRequest.IsSub = requestedSummoner.IsSub;
                    updateList.Add(oldSummonerRequest);
                }
            }

            //delete
            foreach (var oldEntity in kvp)
            {
                if (!view.RequestedSummoners.Select(x => x.SummonerName).Contains(oldEntity.Key))
                {
                    deleteList.Add(oldEntity.Value);
                }
            }

            var createTask = _requestedSummonerRepository.CreateAsync(createList);
            var updateTask = _requestedSummonerRepository.UpdateAsync(updateList);
            var deleteTask = _requestedSummonerRepository.DeleteAsync(deleteList);

            return(await createTask && await updateTask && await deleteTask);
        }
Example #38
0
        private OperationResult <LogEntity> BuildLog(LogSeverity severity, string message, Exception exception, UserEntity user)
        {
            var result = EngineContext.Current.Resolve <OperationResult <LogEntity> >();

            if (exception is ThreadAbortException)
            {
                return(result.AddError(Messages.Logging_ThreadAbortExceptionIsNotAllowedToBeLogged));
            }

            if (!IsEnabled(severity))
            {
                return(result.AddError(Messages.Logging_LogsWithThisTypeOfSeverityIsDisabled));
            }

            result += Save(severity, message, exception.ToFriendlyString(), user);

            return(result);
        }
Example #39
0
 public void Init()
 {
     sessionKey = "";
     account    = new AccountEntity();
     userInfo   = new UserEntity();
 }
Example #40
0
 public ActionResult SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue)
 {
     userApp.SubmitForm(userEntity, userLogOnEntity, keyValue);
     return(Success("操作成功。"));
 }
        public void TestMapper()
        {
            const string VALID_CPF      = "12345678909";
            const string VALID_PASSWORD = "******";

            var password = BCrypt.Net.BCrypt.HashPassword(VALID_PASSWORD, BCrypt.Net.BCrypt.GenerateSalt());

            var listEntityUsers = new List <UserEntity>();

            for (int i = 0; i < 5; i++)
            {
                var user = new UserEntity
                {
                    Id       = Guid.NewGuid(),
                    Name     = Faker.Name.FullName(),
                    Email    = Faker.Internet.Email(),
                    Cpf      = VALID_CPF,
                    Password = password
                };

                listEntityUsers.Add(user);
            }

            var listEntityCurrentAccounts = new List <CurrentAccountEntity>();

            foreach (var user in listEntityUsers)
            {
                var entityCurrentAccount = new CurrentAccountEntity
                {
                    Id      = Guid.NewGuid(),
                    Balance = 100,
                    UserId  = user.Id
                };

                listEntityCurrentAccounts.Add(entityCurrentAccount);
            }

            var modelUser = new UserModel
            {
                Id       = Guid.NewGuid(),
                Name     = Faker.Name.FullName(),
                Email    = Faker.Internet.Email(),
                Cpf      = VALID_CPF,
                Password = password
            };

            var modelCurrentAccount = new CurrentAccountModel
            {
                Id      = Guid.NewGuid(),
                Balance = 100,
                UserId  = modelUser.Id
            };

            var entity = Mapper.Map <CurrentAccountEntity>(modelCurrentAccount);

            Assert.Equal(entity.Id, modelCurrentAccount.Id);
            Assert.Equal(entity.Balance, modelCurrentAccount.Balance);
            Assert.Equal(entity.UserId, modelCurrentAccount.UserId);

            var dto = Mapper.Map <CurrentAccountDtoResult>(entity);

            Assert.Equal(dto.Id, entity.Id);
            Assert.Equal(dto.Balance, entity.Balance);
            Assert.Equal(dto.UserId, entity.UserId);

            var listEntityToListDto = Mapper.Map <List <CurrentAccountDtoResult> >(listEntityCurrentAccounts);

            Assert.True(listEntityToListDto.Count() == listEntityCurrentAccounts.Count());
            for (int i = 0; i < listEntityToListDto.Count(); i++)
            {
                Assert.Equal(listEntityToListDto[i].Id, listEntityCurrentAccounts[i].Id);
                Assert.Equal(listEntityToListDto[i].Balance, listEntityCurrentAccounts[i].Balance);
                Assert.Equal(listEntityToListDto[i].UserId, listEntityCurrentAccounts[i].UserId);
            }

            var userDtoResult = Mapper.Map <CurrentAccountDtoResult>(entity);

            Assert.Equal(userDtoResult.Id, entity.Id);
            Assert.Equal(userDtoResult.Balance, entity.Balance);
            Assert.Equal(userDtoResult.UserId, entity.UserId);
        }
Example #42
0
        private static UserEntity GetUser(Guid id)
        {
            UserEntity userEntity = _userRepo.Get(user => user.Id == id).FirstOrDefault();

            return(userEntity);
        }
Example #43
0
 public async Task <IdentityResult> AddUserAsync(UserEntity user, string password)
 {
     return(await _userManager.CreateAsync(user, password));
 }
Example #44
0
 public async Task AddUserToRoleAsync(UserEntity user, string roleName)
 {
     await _userManager.AddToRoleAsync(user, roleName);
 }
Example #45
0
 public UsersTestsEntity GetLastResult(UserEntity user)
 {
     return(usersTestsRepository.GetLastResult(user.ToDalUser()).ToBllUsersTest());
 }
        private void SetSiteProperties(Func <TenantOperationMessage, bool> timeoutFunction)
#endif
        {
            var props          = GetSiteProperties(Url);
            var updateRequired = false;

            if (ParameterSpecified(nameof(Title)))
            {
                props.Title    = Title;
                updateRequired = true;
            }

            if (ParameterSpecified(nameof(DenyAddAndCustomizePages)))
            {
                props.DenyAddAndCustomizePages = DenyAddAndCustomizePages ? DenyAddAndCustomizePagesStatus.Enabled : DenyAddAndCustomizePagesStatus.Disabled;
                updateRequired = true;
            }

            if (ParameterSpecified(nameof(LocaleId)))
            {
                props.Lcid     = LocaleId;
                updateRequired = true;
            }

            if (ParameterSpecified(nameof(AllowSelfServiceUpgrade)))
            {
                props.AllowSelfServiceUpgrade = AllowSelfServiceUpgrade;
                updateRequired = true;
            }

#if !ONPREMISES
            if (ParameterSpecified(nameof(SharingAllowedDomainList)))
            {
                props.SharingAllowedDomainList = SharingAllowedDomainList;
                updateRequired = true;
            }
            if (ParameterSpecified(nameof(SharingBlockedDomainList)))
            {
                props.SharingBlockedDomainList = SharingBlockedDomainList;
                updateRequired = true;
            }
            if (ParameterSpecified(nameof(SharingDomainRestrictionMode)))
            {
                props.SharingDomainRestrictionMode = SharingDomainRestrictionMode;
                updateRequired = true;
            }
#pragma warning disable CS0618 // Type or member is obsolete
            if (ParameterSpecified(nameof(UserCodeMaximumLevel)))
            {
                props.UserCodeMaximumLevel = UserCodeMaximumLevel;
                updateRequired             = true;
            }
            if (ParameterSpecified(nameof(UserCodeWarningLevel)))
            {
                props.UserCodeWarningLevel = UserCodeWarningLevel;
                updateRequired             = true;
            }
#pragma warning restore CS0618 // Type or member is obsolete
            if (ParameterSpecified(nameof(StorageMaximumLevel)))
            {
                props.StorageMaximumLevel = StorageMaximumLevel;
                updateRequired            = true;
            }
            if (ParameterSpecified(nameof(StorageWarningLevel)))
            {
                props.StorageWarningLevel = StorageWarningLevel;
                updateRequired            = true;
            }
            if (ParameterSpecified(nameof(SharingCapability)))
            {
                props.SharingCapability = SharingCapability;
                updateRequired          = true;
            }
            if (ParameterSpecified(nameof(DefaultLinkPermission)))
            {
                props.DefaultLinkPermission = DefaultLinkPermission;
                updateRequired = true;
            }
            if (ParameterSpecified(nameof(DefaultSharingLinkType)))
            {
                props.DefaultSharingLinkType = DefaultSharingLinkType;
                updateRequired = true;
            }

            if (ParameterSpecified(nameof(BlockDownloadOfNonViewableFiles)))
            {
                props.AllowDownloadingNonWebViewableFiles = !BlockDownloadOfNonViewableFiles;
                updateRequired = true;
            }

            if (ParameterSpecified(nameof(CommentsOnSitePagesDisabled)))
            {
                props.CommentsOnSitePagesDisabled = CommentsOnSitePagesDisabled;
                updateRequired = true;
            }

            if (ParameterSpecified(nameof(DisableAppViews)))
            {
                props.DisableAppViews = DisableAppViews;
                updateRequired        = true;
            }

            if (ParameterSpecified(nameof(DisableCompanyWideSharingLinks)))
            {
                props.DisableCompanyWideSharingLinks = DisableCompanyWideSharingLinks;
                updateRequired = true;
            }

            if (ParameterSpecified(nameof(DisableFlows)))
            {
                props.DisableFlows = DisableFlows;
                updateRequired     = true;
            }
#endif

            if (updateRequired)
            {
                var op = props.Update();
                ClientContext.Load(op, i => i.IsComplete, i => i.PollingInterval);
                ClientContext.ExecuteQueryRetry();

#if !ONPREMISES
                if (Wait)
                {
                    WaitForIsComplete(ClientContext, op, timeoutFunction, TenantOperationMessage.SettingSiteProperties);
                }
#endif
            }

            if (Owners != null && Owners.Count > 0)
            {
                var admins = new List <UserEntity>();
                foreach (var owner in Owners)
                {
                    var userEntity = new UserEntity {
                        LoginName = owner
                    };
                    admins.Add(userEntity);
                }
                Tenant.AddAdministrators(admins, new Uri(Url));
            }
        }
Example #47
0
        public OperationResult <LogEntity> Save(LogSeverity severity, string fullMessage, string stackTrace, UserEntity invoker)
        {
            var result = EngineContext.Current.Resolve <OperationResult <LogEntity> >();

            var webHelper = EngineContext.Current.Resolve <IWebHelper>();

            var log = new LogEntity {
                IsEnabled   = true,
                Severity    = severity,
                LogDateUtc  = DateTime.UtcNow,
                FullMessage = fullMessage,
                StackTrace  = stackTrace,
                RequestUrl  = webHelper.GetUrl(true, true),
                ReferrerUrl = webHelper.GetReferrer(),
                Invoker     = invoker,
                InvokerIp   = webHelper.GetIpAddress()
            };

            result += Save(log, false);

            return(result.With(log));
        }
Example #48
0
 public bool IsUserTested(UserEntity user)
 {
     return(usersTestsRepository.IsUserTested(user.ToDalUser()));
 }
Example #49
0
 public OperationResult <LogEntity> Fatal(string message, Exception exception = null, UserEntity user = null)
 {
     return(BuildLog(LogSeverity.Fatal, message, exception, user));
 }
Example #50
0
        /// <summary>
        /// 同步用户信息到培训平台
        /// </summary>
        /// <param name="user">用户基本信息</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        public string SyncUser(UserEntity user, string pwd, ERCHTMS.Code.Operator currUser = null)
        {
            string logPath  = new DataItemDetailService().GetItemValue("imgPath") + "\\logs\\";
            string fileName = "Train_" + DateTime.Now.ToString("yyyyMMdd") + ".log";

            try
            {
                string    result = "";
                DataTable dt     = BaseRepository().FindTable(string.Format("select px_deptid from xss_dept where deptid='{0}'", user.DepartmentId));
                if (dt.Rows.Count > 0)
                {
                    string deptId = dt.Rows[0][0].ToString();
                    pwd  = pwd.Replace("*", "");
                    user = DbFactory.Base().FindEntity <UserEntity>(user.UserId);
                    if (string.IsNullOrEmpty(user.NewPassword))
                    {
                        pwd = string.IsNullOrEmpty(pwd) ? "123456" : pwd;
                    }
                    else
                    {
                        pwd = DESEncrypt.Decrypt(user.NewPassword, user.Secretkey);
                    }
                    List <object> list = new List <object>();
                    list.Add(new
                    {
                        Id          = user.UserId,
                        userName    = user.RealName,
                        userAccount = user.Account,
                        pwd         = pwd,
                        IdCard      = user.IdentifyID,
                        departid    = deptId,
                        role        = "0",
                        userkind    = "一般人员",
                        telephone   = user.Mobile
                    });
                    if (user.IsTrainAdmin == 1)
                    {
                        string str  = user.IdentifyID.Substring(0, user.IdentifyID.Length - 1);
                        string last = user.IdentifyID.Substring(user.IdentifyID.Length - 1);
                        if (last.ToLower().Equals("x") || !last.Equals("0"))
                        {
                            last = "1";
                        }
                        else
                        {
                            last = "0";
                        }
                        list.Add(new
                        {
                            Id          = Guid.NewGuid().ToString(),
                            userName    = user.RealName,
                            userAccount = user.Account + "gly",
                            pwd         = pwd,
                            IdCard      = str + last,
                            departid    = deptId,
                            role        = "1",
                            userkind    = "一般人员",
                            telephone   = user.Mobile
                        });
                    }
                    WebClient wc = new WebClient();
                    wc.Credentials = CredentialCache.DefaultCredentials;
                    //wc.Headers.Add("Content-Type", "text/json; charset=utf-8");
                    wc.Encoding = Encoding.GetEncoding("GB2312");
                    System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection();
                    byte[] bytes = null;
                    //发送请求到web api并获取返回值,默认为post方式
                    string url  = new DataItemDetailService().GetItemValue("TrainServiceUrl");
                    string json = Newtonsoft.Json.JsonConvert.SerializeObject(new { business = "saverUser", UserInfo = list });
                    nc.Add("json", json);
                    bytes  = wc.UploadValues(new Uri(url), "POST", nc);
                    result = Encoding.UTF8.GetString(bytes);
                    dynamic dy = Newtonsoft.Json.JsonConvert.DeserializeObject <ExpandoObject>(result);

                    if (dy.meta.success)
                    {
                        int count = BaseRepository().FindObject(string.Format("select count(1) from xss_user where useraccount='{0}'", user.Account)).ToInt();
                        if (count == 0)
                        {
                            if (BaseRepository().ExecuteBySql(string.Format("insert into xss_user(userid,useraccount,username,deptid,deptcode,px_deptid,px_uid,px_account,idcard) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", user.UserId, user.Account, user.RealName, user.DepartmentId, user.DepartmentCode, deptId, user.UserId, user.Account, user.IdentifyID)) > 0)
                            {
                                System.IO.File.AppendAllText(logPath + fileName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " >操作用户:" + currUser.Account + "(" + currUser.UserName + "),新增用户关联信息到双控平台成功,用户信息:" + json + "\r\n");
                            }
                            else
                            {
                                System.IO.File.AppendAllText(logPath + fileName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " >操作用户:" + currUser.Account + "(" + currUser.UserName + "),新增用户关联信息到双控平台失败,用户信息:" + json + " \r\n");
                            }
                        }
                    }
                    System.IO.File.AppendAllText(logPath + fileName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " >操作用户:" + currUser.Account + "(" + currUser.UserName + "),执行动作:同步用户到培训平台,返回结果:" + result + "\r\n");
                }
                else
                {
                    System.IO.File.AppendAllText(logPath + fileName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " >操作用户:" + currUser.Account + "(" + currUser.UserName + "),执行动作:同步用户到培训平台,返回结果:\r\n");
                }
                return(result);
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(logPath + fileName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " >:" + currUser.Account + "(" + currUser.UserName + "),同步用户到培训平台失败,该用户所属部门在培训平台中不存在或关系未配置!\r\n");
                return(ex.Message);
            }
        }
Example #51
0
        protected override void ExecuteCmdlet()
        {
            var context = ClientContext;
            var site    = ClientContext.Site;
            var siteUrl = ClientContext.Url;

            var executeQueryRequired = false;

            if (!string.IsNullOrEmpty(Identity))
            {
                context = ClientContext.Clone(Identity);
                site    = context.Site;
                siteUrl = context.Url;
            }

#if !SP2013 && !SP2016
            if (ParameterSpecified(nameof(Classification)))
            {
                site.Classification  = Classification;
                executeQueryRequired = true;
            }
#endif
#if !ONPREMISES
            if (ParameterSpecified(nameof(LogoFilePath)))
            {
                site.EnsureProperty(s => s.GroupId);
                if (site.GroupId != Guid.Empty)
                {
                    if (!System.IO.Path.IsPathRooted(LogoFilePath))
                    {
                        LogoFilePath = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, LogoFilePath);
                    }
                    if (System.IO.File.Exists(LogoFilePath))
                    {
                        var bytes = System.IO.File.ReadAllBytes(LogoFilePath);
#if !NETSTANDARD2_1
                        var mimeType = System.Web.MimeMapping.GetMimeMapping(LogoFilePath);
#else
                        var mimeType = "";
                        if (LogoFilePath.EndsWith("gif", StringComparison.InvariantCultureIgnoreCase))
                        {
                            mimeType = "image/gif";
                        }
                        if (LogoFilePath.EndsWith("jpg", StringComparison.InvariantCultureIgnoreCase))
                        {
                            mimeType = "image/jpeg";
                        }
                        if (LogoFilePath.EndsWith("png", StringComparison.InvariantCultureIgnoreCase))
                        {
                            mimeType = "image/png";
                        }
#endif
                        var result = OfficeDevPnP.Core.Sites.SiteCollection.SetGroupImageAsync(context, bytes, mimeType).GetAwaiter().GetResult();
                    }
                    else
                    {
                        throw new System.Exception("Logo file does not exist");
                    }
                }
                else
                {
                    throw new System.Exception("Not an Office365 group enabled site.");
                }
            }
#endif
            if (executeQueryRequired)
            {
                context.ExecuteQueryRetry();
            }

            if (IsTenantProperty())
            {
#if ONPREMISES
                string tenantAdminUrl;
                if (!string.IsNullOrEmpty(SPOnlineConnection.CurrentConnection.TenantAdminUrl))
                {
                    tenantAdminUrl = SPOnlineConnection.CurrentConnection.TenantAdminUrl;
                }
                else if (SPOnlineConnection.CurrentConnection.ConnectionType == Enums.ConnectionType.TenantAdmin)
                {
                    tenantAdminUrl = ClientContext.Url;
                }
                else
                {
                    throw new InvalidOperationException(Properties.Resources.NoTenantAdminUrlSpecified);
                }
#else
                var tenantAdminUrl = UrlUtilities.GetTenantAdministrationUrl(context.Url);
#endif
                context = context.Clone(tenantAdminUrl);

                executeQueryRequired = false;
                Func <TenantOperationMessage, bool> timeoutFunction = TimeoutFunction;
                Tenant tenant         = new Tenant(context);
                var    siteProperties = tenant.GetSitePropertiesByUrl(siteUrl, false);

#if !ONPREMISES
                if (LockState.HasValue)
                {
                    tenant.SetSiteLockState(siteUrl, LockState.Value, Wait, Wait ? timeoutFunction : null);
                    WriteWarning("You changed the lockstate of this site. This change is not guaranteed to be effective immediately. Please wait a few minutes for this to take effect.");
                }
#endif
                if (Owners != null && Owners.Count > 0)
                {
                    var admins = new List <UserEntity>();
                    foreach (var owner in Owners)
                    {
                        var userEntity = new UserEntity {
                            LoginName = owner
                        };
                        admins.Add(userEntity);
                    }
                    tenant.AddAdministrators(admins, new Uri(siteUrl));
                }
#if !ONPREMISES
                if (Sharing.HasValue)
                {
                    siteProperties.SharingCapability = Sharing.Value;
                    executeQueryRequired             = true;
                }
                if (StorageMaximumLevel.HasValue)
                {
                    siteProperties.StorageMaximumLevel = StorageMaximumLevel.Value;
                    executeQueryRequired = true;
                }
                if (StorageWarningLevel.HasValue)
                {
                    siteProperties.StorageWarningLevel = StorageWarningLevel.Value;
                    executeQueryRequired = true;
                }
#pragma warning disable CS0618 // Type or member is obsolete
                if (UserCodeWarningLevel.HasValue)
                {
                    siteProperties.UserCodeWarningLevel = UserCodeWarningLevel.Value;
                    executeQueryRequired = true;
                }
                if (UserCodeMaximumLevel.HasValue)
                {
                    siteProperties.UserCodeMaximumLevel = UserCodeMaximumLevel.Value;
                    executeQueryRequired = true;
                }
#endif
#pragma warning restore CS0618 // Type or member is obsolete

                if (AllowSelfServiceUpgrade.HasValue)
                {
                    siteProperties.AllowSelfServiceUpgrade = AllowSelfServiceUpgrade.Value;
                    executeQueryRequired = true;
                }
                if (NoScriptSite.HasValue)
                {
                    siteProperties.DenyAddAndCustomizePages = (NoScriptSite == true ? DenyAddAndCustomizePagesStatus.Enabled : DenyAddAndCustomizePagesStatus.Disabled);
                    executeQueryRequired = true;
                }
#if !ONPREMISES
                if (CommentsOnSitePagesDisabled.HasValue)
                {
                    siteProperties.CommentsOnSitePagesDisabled = CommentsOnSitePagesDisabled.Value;
                    executeQueryRequired = true;
                }
                if (DefaultLinkPermission.HasValue)
                {
                    siteProperties.DefaultLinkPermission = DefaultLinkPermission.Value;
                    executeQueryRequired = true;
                }
                if (DefaultSharingLinkType.HasValue)
                {
                    siteProperties.DefaultSharingLinkType = DefaultSharingLinkType.Value;
                    executeQueryRequired = true;
                }
                if (DisableAppViews.HasValue)
                {
                    siteProperties.DisableAppViews = DisableAppViews.Value;
                    executeQueryRequired           = true;
                }
                if (DisableCompanyWideSharingLinks.HasValue)
                {
                    siteProperties.DisableCompanyWideSharingLinks = DisableCompanyWideSharingLinks.Value;
                    executeQueryRequired = true;
                }
                if (DisableFlows.HasValue)
                {
                    siteProperties.DisableFlows = DisableFlows.Value ? FlowsPolicy.Disabled : FlowsPolicy.NotDisabled;
                    executeQueryRequired        = true;
                }
#endif
                if (LocaleId.HasValue)
                {
                    siteProperties.Lcid  = LocaleId.Value;
                    executeQueryRequired = true;
                }
                //if (!string.IsNullOrEmpty(NewUrl))
                //{
                //    siteProperties.NewUrl = NewUrl;
                //    executeQueryRequired = true;
                //}
#if !ONPREMISES
                if (RestrictedToGeo.HasValue)
                {
                    siteProperties.RestrictedToRegion = RestrictedToGeo.Value;
                    executeQueryRequired = true;
                }
                if (SocialBarOnSitePagesDisabled.HasValue)
                {
                    siteProperties.SocialBarOnSitePagesDisabled = SocialBarOnSitePagesDisabled.Value;
                    executeQueryRequired = true;
                }
#endif
                if (executeQueryRequired)
                {
                    siteProperties.Update();
                    tenant.Context.ExecuteQueryRetry();
                }

#if !ONPREMISES
                if (DisableSharingForNonOwners.IsPresent)
                {
                    Office365Tenant office365Tenant = new Office365Tenant(context);
                    context.Load(office365Tenant);
                    context.ExecuteQueryRetry();
                    office365Tenant.DisableSharingForNonOwnersOfSite(siteUrl);
                    context.ExecuteQuery();
                }
#endif
            }
        }
Example #52
0
 private object SuccessObject(DateTime createDate, DateTime expirationDate, string token, UserEntity user)
 {
     return(new
     {
         authenticated = true,
         created = createDate.ToString("yyyy-MM-dd HH:mm:ss"),
         expiration = expirationDate.ToString("yyyy-MM-dd HH:mm:ss"),
         acessToken = token,
         userName = user.Email,
         name = user.Name,
         message = "Login accepted"
     });
 }
 public void Add(UserEntity entity)
 {
     this.db.Users.Add(entity);
 }
Example #54
0
 public void UpdateForm(UserEntity userEntity)
 {
     service.Update(userEntity);
 }
        public async Task <SummonerRequestView> GetRequestedSummonersAsync(UserEntity user)
        {
            var seasonInfo = await _seasonInfoRepository.GetCurrentSeasonAsync();

            var summoners      = (await _summonerInfoRepository.GetAllValidSummonersAsync()).ToList();
            var summonerEntity = summoners.First(x => x.UserId == user.Id);

            summoners.Remove(summonerEntity);
            if (summonerEntity.IsAcademyPlayer)
            {
                summoners = summoners.Where(x => x.IsAcademyPlayer).ToList();
            }

            var requestedSummonerEntities = (await _requestedSummonerRepository.ReadAllForSummonerAsync(summonerEntity.Id, seasonInfo.Id)).ToList();
            var view = new SummonerRequestView
            {
                SummonerName  = summonerEntity.SummonerName,
                SummonerNames = summoners.Select(x => x.SummonerName).OrderBy(x => x).ToList(),
                Names         = GetSelectListItems(summoners.Select(x => x.SummonerName).OrderBy(x => x))
            };

            if (!requestedSummonerEntities.Any())
            {
                var count = RequestingSummonerCount;
                if (summonerEntity.IsAcademyPlayer)
                {
                    count = 1;
                }
                view.RequestedSummoners.AddRange(AddEmptyRequestedSummonerViews(count));
            }
            else
            {
                var requestedSummoners = new List <RequestedSummoner>();

                foreach (var entity in requestedSummonerEntities)
                {
                    var summoner = summoners.First(x => x.Id == entity.SummonerRequestedId);
                    requestedSummoners.Add(new RequestedSummoner
                    {
                        SummonerName = summoner.SummonerName,
                        IsSub        = entity.IsSub
                    });
                }

                view.RequestedSummoners = requestedSummoners;

                var missingCount = RequestingSummonerCount - view.RequestedSummoners.Count;
                if (summonerEntity.IsAcademyPlayer)
                {
                    missingCount = 1 - view.RequestedSummoners.Count;
                }

                view.RequestedSummoners.AddRange(AddEmptyRequestedSummonerViews(missingCount));
            }

            if (!summonerEntity.IsAcademyPlayer)
            {
                SetIsSubToElements(view);
            }

            return(view);
        }
Example #56
0
        /// <summary>
        /// This ensures that the user profile has been created on Authorize.Net CIM.
        /// This is only called when Adding or Editing a card or finalizing a purchase.  All other viewing using the card cache table.
        /// </summary>
        /// <param name="outGateway">The customer gateway created and used to verify the customer has been created.
        /// Just returned for efficiency, there is no consequence to creating another gateway in the calling function</param>
        /// <param name="user">The current user.</param>
        /// <returns>All the customer information from CIM.</returns>
        private Customer EnsureProfile(out CustomerGateway outGateway, UserEntity user = null)
        {
            if (user == null)
            {
                user = Membership.GetUser().GetUserEntity();
            }

            // create the authorize.net gateway
            bool live;

            bool.TryParse(ConfigurationManager.AppSettings.Get("AuthorizeLive"), out live);
            var cg = new CustomerGateway(ConfigurationManager.AppSettings.Get("API_LOGIN_ID"),
                                         ConfigurationManager.AppSettings.Get("TRANSACTION_KEY"), live ? ServiceMode.Live : ServiceMode.Test);

            outGateway = cg;

            // get the users e-mail address
            var email   = user.EmailAddress;
            var setting = user.Settings.FirstOrDefault(x => x.Name == "SupportUser");

            if (setting != null)
            {
                email = setting.Value + "@" + SupportController.DOMAIN;
            }

            // create a new customer profile for the currently logged in user
            var profile = new UserSettingEntity(user.UserId, "AuthorizeId");

            if (profile.IsNew)
            {
                try
                {
                    // set up new user
                    profile.UserId = user.UserId;
                    profile.Name   = "AuthorizeId";
                    var customer = cg.CreateCustomer(email, user.Username);
                    profile.Value = customer.ProfileID;
                    profile.Save();

                    return(customer);
                }
                catch (Exception ex)
                {
                    // user exists, so just get the ID
                    if (ex.Message.Contains("duplicate"))
                    {
                        profile.UserId = user.UserId;
                        profile.Name   = "AuthorizeId";
                        var start = ex.Message.IndexOf("ID", StringComparison.InvariantCulture) + 3;
                        profile.Value = ex.Message.Substring(start,
                                                             ex.Message.IndexOf(" ", start,
                                                                                StringComparison.InvariantCulture) -
                                                             start);
                        profile.Save();
                    }
                    Log.Error(Purchase.AuthError, ex);
                }
            }

            var existingCustomer = cg.GetCustomer(profile.Value);

            if (existingCustomer.Email != email)
            {
                existingCustomer.Email = email;
                cg.UpdateCustomer(existingCustomer);
            }


            return(existingCustomer);
        }
Example #57
0
 public void StartTest(UserEntity user, TestEntity test)
 {
     usersTestsRepository.StartTest(user.ToDalUser(), test.ToDalTest());
     uow.Commit();
 }
Example #58
0
 public static void MapIntegrationInfoUserToUserEntity(this UserEntity userEntity, IntegrationInfoUser baseUser)
 {
     userEntity.MapBaseUserToUserEntity(baseUser);
     userEntity.ChatIntegrations = baseUser.IntegrationsDetails?.Select(x => x.MapDerivedIntegrationEntity()).ToList();
 }
        protected override void Seed(CensusContext context)
        {
            var approver = new UserEntity {
                FirstMidName = "Admin", LastName = "DashBoard", Email = "*****@*****.**", Password = "******", IsApprover = true, ProfileImage = "https://firebasestorage.googleapis.com/v0/b/demoproject-1287a.appspot.com/o/admin.png?alt=media&token=6290a56e-84bb-4909-93f1-131bf9ef9f66", AdhaarNumber = "232323232323", CurrentStatus = 0, ApprovedBy = 0
            };

            context.Users.AddOrUpdate(approver);
            context.SaveChanges();

            var house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "13AB",
                Line1             = "House No : 55",
                StreetName        = "King's Street",
                City              = "Delhi",
                State             = "Delhi",
                HeadOfFamily      = "Mr. AAA",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 132011783695550347
            };

            context.Houses.AddOrUpdate(house);
            house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "15AB",
                Line1             = "Flat No : 55",
                StreetName        = "King's Street",
                City              = "Goa",
                State             = "Goa",
                HeadOfFamily      = "Mr. BBB",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 0000000000000004
            };
            context.Houses.AddOrUpdate(house);
            house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "122AB",
                Line1             = "House No : 523",
                StreetName        = "King's Street",
                City              = "Ahemdabad",
                State             = "Gujrat",
                HeadOfFamily      = "Mr. XXX",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 0000000000000002
            };
            context.Houses.AddOrUpdate(house);
            house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "122AB",
                Line1             = "House No : 120",
                StreetName        = "King's Street",
                City              = "Kanpur",
                State             = "Uttar Pradesh",
                HeadOfFamily      = "Mr. XYZ",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 0000000000000003
            };
            context.Houses.AddOrUpdate(house);
            context.SaveChanges();


            //var person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 0000000000000003,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Male,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "Student",
            //    NatureOfWork = "studying",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 0000000000000001,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Male,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "IT",
            //    NatureOfWork = "studying",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 132011783695550347,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Female,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "Teacher",
            //    NatureOfWork = "Government Job",
            //    CreatedBy = 0
            //};

            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 132011783695550347,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Female,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "IT",
            //    NatureOfWork = "private job",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 0000000000000002,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Male,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "IT",
            //    NatureOfWork = "private job",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
        }
Example #60
0
 public async Task <bool> IsUserInRoleAsync(UserEntity user, string roleName)
 {
     return(await _userManager.IsInRoleAsync(user, roleName));
 }