예제 #1
0
        public void ShouldAddANewUserRoleToList()
        {
            //arrange
            var newitem = new UserRole
            {
                userroleid = 12, userid = 12
            };

            //act
            _mockrepo.Add(newitem);
            var obj = _mockrepo.FindByID(12);

            //assert
            Assert.AreEqual(12, obj.userid);
        }
예제 #2
0
        public async Task <ActionResult> Add(EM_User_Role model, string CompanyIds, string ProgramIds)
        {
            model.CompanyIds = CompanyIds;
            userRoleRepo.Add(model);
            var result = userRoleRepo.SaveChanges();

            userRightRepo.UpdateUserRoleRight(model.Id, ProgramIds);
            if (result > 0)
            {
                return(Json(new { code = 1 }));
            }
            else
            {
                return(Json(new { code = 0, message = "保存失败,请重试" }));
            }
        }