public JsonResult InsertOrUpdate(Admins input) { ResultDto <int> result = new ResultDto <int>(); try { using (AdminsService Admin = new AdminsService()) { if (input.Id == 0) { input.CreationTime = DateTime.Now; } Admin.Reposity.InsertOrUpdate(input); result.code = 100; result.datas = input.Id; result.message = "ok"; } } catch (Exception ex) { result.code = 500; result.message = ex.Message; } return(Json(result)); }
public SettingMsController() { db = new CloudControlEntities(); adminsService = new AdminsService(db); limsService = new LimsService(db); adminlimsService = new AdminLimsService(db); }
public void GetRules() { adminsService = new AdminsService(adminRepositoryMock.Object, carRepositoryMock.Object, ownerRepositoryMock.Object, ruleRepositoryMock.Object); Assert.IsNotNull(adminsService.GetRules()); }
public void GetCarByBodySeries() { adminsService = new AdminsService(adminRepositoryMock.Object, carRepositoryMock.Object, ownerRepositoryMock.Object, ruleRepositoryMock.Object); Assert.IsNotNull(adminsService.GetCarByBodySeries("bodyseriesI")); }
public SettingMsController() { db = new HeOEntities(); adminsService = new AdminsService(); limsService = new LimsSerivce(); adminlimsService = new AdminLimsService(); }
public ActionResult Index() { AdminWithTenant models = new AdminWithTenant(); if (AdminId > 0) { using (AdminsService admin = new AdminsService()) { var model = admin.Reposity.Get(AdminId); models.Admin = Mapper.Map <AdminDto>(model); } using (TenantsService tenantS = new TenantsService()) { var model = tenantS.Reposity.Get(TenantId); if (model != null) { models.Tenant = Mapper.Map <TenantDto>(model); } else { models.Tenant = new TenantDto() { TenantName = "暂无站点", Id = 0 }; } } } return(View(models)); }
public JsonResult Login(string LoginName, string Password) { Studio.Dto.ResultDto <string> result = new Studio.Dto.ResultDto <string>(); using (AdminsService admin = new AdminsService()) { var model = admin.Reposity.GetAllList().Where(o => o.LoginName == LoginName).FirstOrDefault(); if (model != null) { if (model.Password == Password) { result.code = 100; result.message = "success"; AppBase.SetCookie("AdminId", model.Id.ToString(), 1); } else { result.code = 101; result.message = "Password error"; } } else { result.code = 102; result.message = "Not exist"; } } return(Json(result)); }
public ClientsController(UserManager <ApplicationUser> userManager, ClientsService clientsService, AdminsService adminsService, MedicsService medicsService) { _userManager = userManager; this.clientsService = clientsService; this.adminsService = adminsService; this.medicsService = medicsService; }
public JsonResult GetLists(int page, int pageSize) { AdminsService Admin = new AdminsService(); var result = Admin.Reposity.GetPageList(page, pageSize); var lists = Mapper.Map <ResultDto <List <Dto.AdminDto> > >(result); return(Json(lists)); }
public JsonResult GetModel(int id) { Admins model = new Admins(); AdminsService Admin = new AdminsService(); var result = Admin.Reposity.FirstOrDefault(id); if (result != null) { model = result; } return(Json(model)); }
public void GetAdminById_ThrowsException_InvalidId() { adminsService = new AdminsService(adminRepositoryMock.Object, carRepositoryMock.Object, ownerRepositoryMock.Object, ruleRepositoryMock.Object); var invalidAdminId = "invalid"; Assert.ThrowsException <Exception>(() => { adminsService.GetAdminById(invalidAdminId); }); }
public RegisterModel( UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager, ILogger <RegisterModel> logger, ClientsService clientsService, AdminsService adminsService, IEmailSender emailSender) { _userManager = userManager; _signInManager = signInManager; _logger = logger; _emailSender = emailSender; this.clientsService = clientsService; this.adminsService = adminsService; }
public void GetCountOfPhotosCommentsShouldWorkCorrectly() { var comments = new List <Comment>(); var photos = new List <Photo>(); var mockCommentRepo = new Mock <IDeletableEntityRepository <Comment> >(); mockCommentRepo.Setup(x => x.All()).Returns(comments.AsQueryable()); mockCommentRepo.Setup(x => x.AddAsync(It.IsAny <Comment>())).Callback((Comment comm) => comments.Add(comm)); var mockPhoto = new Mock <IDeletableEntityRepository <Photo> >(); mockPhoto.Setup(x => x.All()).Returns(photos.AsQueryable()); mockPhoto.Setup(x => x.AddAsync(It.IsAny <Photo>())).Callback((Photo ph) => photos.Add(ph)); var service = new AdminsService(null, mockCommentRepo.Object, mockPhoto.Object, null, null); var photo = new Photo { Id = "1", ImagePath = "/images/photos", }; var comment = new Comment { Id = "1", ImagePath = "/images/photos", PhotoId = "1", UserId = "1", SentById = "1", }; var secondComment = new Comment { Id = "2", ImagePath = "/images/photos", PhotoId = "1", UserId = "1", SentById = "1", }; photos.Add(photo); comments.Add(comment); comments.Add(secondComment); var result = service.GetCountOfPhotosComments(); var expectedResult = 2; Assert.Equal(expectedResult, result); }
public JsonResult Del(int id) { Studio.Dto.ResultDto <string> result = new Studio.Dto.ResultDto <string>(); try { AdminsService Admin = new AdminsService(); Admin.Reposity.Delete(id); result.code = 100; result.message = "success"; } catch (Exception ex) { result.message = ex.Message; } return(Json(result)); }
private void buttonOk_Click(object sender, EventArgs e) { string username = textBoxUser.Text; string password = textBoxPsw.Text; int tenantid = AppBase.CInt(comboBoxTenant.SelectedValue); int cateid = AppBase.CInt(comboBoxCate.SelectedValue); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { MessageBox.Show("请输入用户名和密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (tenantid == 0) { MessageBox.Show("请选择站点!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cateid == 0) { MessageBox.Show("请选择社区!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (AdminsService admin = new AdminsService()) { var model = admin.Reposity.GetAllList().Where(o => o.LoginName == username).FirstOrDefault(); if (model != null) { if (model.Password == password) { FormMain form = new FormMain(tenantid, cateid, model.Id, comboBoxCate.Text, model.LoginName); form.Show(); this.Hide(); } else { MessageBox.Show("密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("用户不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public async Task DeletePostShouldWorkCorrectly() { var posts = new List <Post>(); var mockPostRepo = new Mock <IDeletableEntityRepository <Post> >(); mockPostRepo.Setup(x => x.All()).Returns(posts.AsQueryable()); mockPostRepo.Setup(x => x.AddAsync(It.IsAny <Post>())).Callback((Post ps) => posts.Add(ps)); var service = new AdminsService(mockPostRepo.Object, null, null, null, null); var postToDelete = new Post { Id = "123", }; posts.Add(postToDelete); await service.DeletePost("123"); Assert.Equal(true, postToDelete.IsDeleted); }
public async Task DeleteUserShouldWorkCorrectly() { var appUsers = new List <ApplicationUser>(); var mockAppUser = new Mock <IDeletableEntityRepository <ApplicationUser> >(); mockAppUser.Setup(x => x.All()).Returns(appUsers.AsQueryable()); mockAppUser.Setup(x => x.AddAsync(It.IsAny <ApplicationUser>())).Callback((ApplicationUser appU) => appUsers.Add(appU)); var service = new AdminsService(null, null, null, null, mockAppUser.Object); var user = new ApplicationUser { Id = "123", }; appUsers.Add(user); await service.DeleteUser("123"); Assert.Equal(true, user.IsDeleted); }
public void GetAdminById_Returns_AdminExists() { var existingAdminId = Guid.NewGuid(); var admin = new Admin { Id = existingAdminId, UserId = Guid.NewGuid(), FirstName = "firstName", LastName = "lastName" }; adminRepositoryMock.Setup(adminRepositoryMock => adminRepositoryMock.GetAdminByUserId(existingAdminId)).Returns(admin); adminsService = new AdminsService(adminRepositoryMock.Object, carRepositoryMock.Object, ownerRepositoryMock.Object, ruleRepositoryMock.Object); var searchedAdmin = adminsService.GetAdminById(existingAdminId.ToString()); Assert.IsNotNull(searchedAdmin); }
public async Task DeletePhotoShouldWorkCorrectly() { var photos = new List <Photo>(); var mockPhoto = new Mock <IDeletableEntityRepository <Photo> >(); mockPhoto.Setup(x => x.All()).Returns(photos.AsQueryable()); mockPhoto.Setup(x => x.AddAsync(It.IsAny <Photo>())).Callback((Photo ph) => photos.Add(ph)); var service = new AdminsService(null, null, mockPhoto.Object, null, null); var photo = new Photo { Id = "123", }; photos.Add(photo); await service.DeletePhoto("123"); Assert.Equal(true, photo.IsDeleted); }
public void GetAdminById_ThrowsEntityNotFound_AdminDoesntExist() { var nonExistingAdmin = Guid.NewGuid().ToString(); var existingAdmin = Guid.NewGuid(); var admin = new Admin { Id = existingAdmin, FirstName = "firstName", LastName = "lastName", Email = "*****@*****.**" }; adminRepositoryMock.Setup(adminRepositoryMock => adminRepositoryMock.GetAdminByUserId(existingAdmin)).Returns(admin); adminsService = new AdminsService(adminRepositoryMock.Object, carRepositoryMock.Object, ownerRepositoryMock.Object, ruleRepositoryMock.Object); Assert.ThrowsException <EntityNotFoundException>(() => { adminsService.GetAdminById(nonExistingAdmin); }); }
public RegisterModel( UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager, SignInManager <ApplicationUser> signInManager, //AuthentificationService authentificationService, ClientsService clientsService, AdminsService adminsService, MedicsService medicsService, ILogger <RegisterModel> logger, IHostingEnvironment hostingEnvironment, IEmailSender emailSender) { _userManager = userManager; _roleManager = roleManager; _signInManager = signInManager; _hostingEnvironment = hostingEnvironment; _logger = logger; //_emailSender = emailSender; //this.authentificationService = authentificationService; this.clientsService = clientsService; this.adminsService = adminsService; this.medicsService = medicsService; }
public JsonResult GetListsByAdmin() { ResultDto <List <Dto.TenantDto> > lists = new ResultDto <List <Dto.TenantDto> >(); AdminsService adminServ = new AdminsService(); var admin = adminServ.Reposity.Get(AdminId); if (admin != null && admin.ControlTenants != null) { List <int> tenantIds = new List <int>(); foreach (var item in admin.ControlTenants.Split(',')) { tenantIds.Add(int.Parse(item)); } TenantsService Tenant = new TenantsService(); var result = Tenant.Reposity.GetPageList(1, 0, (o => tenantIds.Contains(o.Id))); lists = Mapper.Map <ResultDto <List <Dto.TenantDto> > >(result); if (TenantId == 0 && tenantIds.Count > 0) { AppBase.SetCookie("TenantId", tenantIds.First().ToString(), 1); } } return(Json(lists)); }
public void GetCountOfPhotosShouldWorkCorrectly() { var photos = new List <Photo>(); var mockPhoto = new Mock <IDeletableEntityRepository <Photo> >(); mockPhoto.Setup(x => x.All()).Returns(photos.AsQueryable()); mockPhoto.Setup(x => x.AddAsync(It.IsAny <Photo>())).Callback((Photo ph) => photos.Add(ph)); var service = new AdminsService(null, null, mockPhoto.Object, null, null); var photo = new Photo { Id = "1", ImagePath = "/images/photos", }; photos.Add(photo); var expectedResult = 1; var result = service.GetCountOfPhotos(); Assert.Equal(expectedResult, result); }
public void GetCountOfUsersShouldWorkCorrectly() { var userChars = new List <UserCharacteristic>(); var mockUserChar = new Mock <IDeletableEntityRepository <UserCharacteristic> >(); mockUserChar.Setup(x => x.All()).Returns(userChars.AsQueryable()); mockUserChar.Setup(x => x.AddAsync(It.IsAny <UserCharacteristic>())).Callback((UserCharacteristic uc) => userChars.Add(uc)); var service = new AdminsService(null, null, null, mockUserChar.Object, null); var user = new UserCharacteristic { Id = "1", }; userChars.Add(user); var expectedResult = 1; var result = service.GetCountOfUsers(); Assert.Equal(expectedResult, result); }
public void GetCountOfPostsShouldWorkCorrectly() { var posts = new List <Post>(); var mockPostRepo = new Mock <IDeletableEntityRepository <Post> >(); mockPostRepo.Setup(x => x.All()).Returns(posts.AsQueryable()); mockPostRepo.Setup(x => x.AddAsync(It.IsAny <Post>())).Callback((Post post) => posts.Add(post)); var service = new AdminsService(mockPostRepo.Object, null, null, null, null); var post = new Post { Id = "1", Title = "Can you help me", Content = "I am 16 yo and...", }; posts.Add(post); var result = service.GetCountOfPosts(); var expectedResult = 1; Assert.Equal(expectedResult, result); }
public async Task DeleteCommentShouldWorkCorrectly() { var comments = new List <Comment>(); var mockCommentRepo = new Mock <IDeletableEntityRepository <Comment> >(); mockCommentRepo.Setup(x => x.All()).Returns(comments.AsQueryable()); mockCommentRepo.Setup(x => x.AddAsync(It.IsAny <Comment>())).Callback((Comment comm) => comments.Add(comm)); var service = new AdminsService(null, mockCommentRepo.Object, null, null, null); var newComment = new Comment { Id = "123", Content = "You are sick", PhotoId = "1", IsDeleted = false, }; comments.Add(newComment); await service.DeleteComment("123"); Assert.Equal(true, newComment.IsDeleted); }
public ActionResult _PartialLeftSide() { List <int> powers = new List <int>(); string AdminName = ""; using (AdminsService admin = new AdminsService()) { var model = admin.Reposity.Get(AdminId); if (model != null && model.Powers != null) { AdminName = model.LoginName; foreach (var item in model.Powers.Split(',')) { powers.Add(int.Parse(item)); } } } CategoriesController CateCtrl = new CategoriesController(); var lists = CateCtrl.GetCategoryTree(); lists = lists.Where(o => powers.Contains(o.Id)).ToList(); ViewBag.Admin = AdminName; return(PartialView(lists)); }
public MainController() { adminsService = new AdminsService(); }
public CommonController(AdminsService adminsService, ClientsService clientsService) { this.adminsService = adminsService; this.clientsService = clientsService; }
public AdminsController(AdminsService adminsService, UserManager <ApplicationUser> userManager) { this.adminsService = adminsService; _userManager = userManager; }