public async Task <bool> DeleteTenent(Guid tenentid) { Tenent tenent = await this._db.Tenents.SingleOrDefaultAsync(x => x.Id == tenentid); List <User> users = await this._db.Users.Where(x => x.Tenent.Id == tenent.Id).ToListAsync(); List <Contact> contacts = await this._db.Contacts.Where(x => x.User.Tenent.Id == tenent.Id).ToListAsync(); List <Address> addresses = await this._db.Address.Where(x => x.Contact.User.Tenent.Id == tenent.Id).ToListAsync(); foreach (var address in addresses) { this._db.Address.Remove(address); } foreach (var contact in contacts) { this._db.Contacts.Remove(contact); } foreach (var user in users) { this._db.Users.Remove(user); } this._db.Tenents.Remove(tenent); await this._db.SaveChangesAsync(); return(true); }
public bool AddTenent(Tenent tenent) { this._db.Tenents.Add(tenent); this._db.SaveChanges(); return(true); }
public Tenent GetTenent(Guid id) { Tenent tenet = this._db.Tenents.Include(x => x.Users) .SingleOrDefault(tenet => tenet.Id == id); return(tenet); }
public async Task <bool> AddTenent(Tenent tenent) { this._db.Tenents.Add(tenent); await this._db.SaveChangesAsync(); return(true); }
public bool UpdateTenent(Tenent tenentToBeUpdated) { Tenent tenent = this._db.Tenents.SingleOrDefault(x => x.Id == tenentToBeUpdated.Id); tenent.Name = tenentToBeUpdated.Name; tenent.TenentStrength = tenentToBeUpdated.TenentStrength; this._db.SaveChanges(); return(true); }
public Tenent GetTenentbasedonName(string name) { Tenent tenent = this._db.Tenents.SingleOrDefault(x => x.Name.Equals(name)); if (tenent == null) { return(null); } return(tenent); }
public async Task <Tenent> GetTenentbasedonName(string name) { Tenent tenent = await this._db.Tenents.SingleOrDefaultAsync(x => x.Name.Equals(name)); if (tenent == null) { return(null); } return(tenent); }
public ResultMsg Create(Tenent Tbl) { ResultMsg resultmsg = tenentService.Create(Tbl); if (resultmsg.IsOk) { resultmsg.DisplayMsg = "Saved successfully"; } return(resultmsg); }
public async Task <bool> UpdateTenent(Tenent tenentToBeUpdated) { Tenent tenent = await this._db.Tenents.SingleOrDefaultAsync(x => x.Id == tenentToBeUpdated.Id); tenent.Name = tenentToBeUpdated.Name; tenent.TenentStrength = tenentToBeUpdated.TenentStrength; await this._db.SaveChangesAsync(); return(true); }
public async Task GetTenent() { var tenent = new Tenent(); var id = Guid.NewGuid(); _tenentRepo.Setup(x => x.GetById(id)).ReturnsAsync(tenent); var result = await _tenentcontroller.GetTenetAsPerId(id); //var okresult = result as OkObjectResult; Assert.Equal(tenent, result.Value); }
public async Task GetUserOfTenent_ShouldReturnListOfUser() { var tenetid = Guid.NewGuid(); var tenent = new Tenent(); List <User> users = new List <User>(); _tenentRepo.Setup(x => x.GetById(tenetid)).ReturnsAsync(tenent); _userRepo.Setup(x => x.GetListBasedOnCondition(y => y.Tenent.Id == tenetid)).ReturnsAsync(users); var result = await _userController.GetUsersOfATenent(tenetid); Assert.Equal(users, result.Value); }
public ActionResult <Tenent> AddTenet(DtoTenet dtotenent) { if (ModelState.IsValid) { Tenent tenet = new Tenent { Name = dtotenent.Name, TenentStrength = dtotenent.TenentStrength }; tenet.Id = new Guid(); _db.AddTenent(tenet); return(Ok(tenet)); } return(BadRequest("Not added Tenent")); }
// [SampleJwtAuthorization(Role =new string[] { "superadmin" })] public async Task <ActionResult> UpdateTenent(Guid tenentId, DtoTenet dtotenent) { if (ModelState.IsValid && (await this._tenentRepo.GetById(tenentId) != null)) { Tenent tenent = await this._tenentRepo.GetById(tenentId); tenent.Name = dtotenent.Name; tenent.TenentStrength = dtotenent.TenentStrength; await this._tenentRepo.update(tenent); return(Ok("Updated successfully")); } return(BadRequest("Not updated ")); }
public override void ActivateOptions() { _routingKey = string.Join(".", Tenent.Replace(".", "%2E"), Environment.Replace(".", "%2E"), AppName.Replace(".", "%2E")); _connectionFactory = new ConnectionFactory() { HostName = HostName, VirtualHost = VirtualHost, UserName = UserName, Password = Password, RequestedHeartbeat = RequestedHeartbeat, Port = Port }; _worker = new WorkerThread <LoggingEvent>($"Worker for log4net appender '{Name}'", TimeSpan.FromSeconds((double)FlushInterval), Process); }
public ActionResult UpdateTenent(Guid tenentId, DtoTenet dtotenent) { if (ModelState.IsValid) { Tenent tenent = this._db.GetTenent(tenentId); tenent.Name = dtotenent.Name; tenent.TenentStrength = dtotenent.TenentStrength; bool result = _db.UpdateTenent(tenent); if (result) { return(Ok("Updated successfully")); } } return(BadRequest("Not updated ")); }
// [SampleJwtAuthorization(Role = new string[] { "superadmin" })] public async Task <ActionResult> AddTenet(DtoTenet dtotenent) { if (ModelState.IsValid && dtotenent.TenentStrength > 0) { Tenent tenet = new Tenent { Name = dtotenent.Name, TenentStrength = dtotenent.TenentStrength }; tenet.Id = new Guid(); await _tenentRepo.Add(tenet); return(Ok(tenet)); } return(BadRequest("Not added Tenent")); }
public async Task DeleteTenent_SHouldReturnOk() { var tenentid = Guid.NewGuid(); var tenent = new Tenent(); _tenentRepo.Setup(x => x.GetById(tenentid)).ReturnsAsync(tenent); _tenentRepo.Setup(x => x.Remove(tenent)); var result = await _tenentcontroller.DeleteTenent(tenentid); var okResult = result as OkObjectResult; //assert Assert.NotNull(okResult); Assert.Equal(StatusCodes.Status200OK, okResult.StatusCode); }
public async Task DeleteUser_ShouldReturnOK() { var tenentid = Guid.NewGuid(); var userid = Guid.NewGuid(); var user = new User(); var tenent = new Tenent(); _tenentRepo.Setup(x => x.GetById(tenentid)).ReturnsAsync(tenent); _userRepo.Setup(x => x.GetById(userid)).ReturnsAsync(user); _userRepo.Setup(x => x.Remove(user)); var result = await _userController.DeleteUser(tenentid, userid); var okresult = result as OkObjectResult; Assert.Equal(StatusCodes.Status200OK, okresult.StatusCode); }
// [SampleJwtAuthorization(Role = new string[] { "superadmin" })] public async Task <ActionResult> DeleteTenent(Guid tenentId) { if (tenentId.ToString() == null) { return(BadRequest("bad Request")); } if (await this._tenentRepo.GetById(tenentId) != null) { Tenent tenent = await this._tenentRepo.GetById(tenentId); await this._tenentRepo.Remove(tenent); return(Ok("Deleted Successfully")); } return(BadRequest("Not Deleted")); }
public async Task AddUser() { //Arrange var tenentid = Guid.NewGuid(); var tenent = new Tenent(); var dtouser = new DtoUser(); var user = new User(); _tenentRepo.Setup(x => x.GetById(tenentid)).ReturnsAsync(tenent); _userRepo.Setup(x => x.Add(user)); //Act var result = await _userController.AddUser(dtouser, tenentid); var okresult = result as OkObjectResult; //Assert Assert.Equal(StatusCodes.Status200OK, okresult.StatusCode); }
public async void AddTenentTest() { DtoTenet tenent = new DtoTenet { Name = "demo", TenentStrength = 100 }; Tenent tenent1 = new Tenent { Name = "demo" }; _tenentRepo.Setup(x => x.Add(tenent1)); var result = await _tenentcontroller.AddTenet(tenent); var okResult = result as OkObjectResult; //assert Assert.NotNull(okResult); Assert.Equal(StatusCodes.Status200OK, okResult.StatusCode); }
public async Task AddContact() { var tenentid = Guid.NewGuid(); var tenent = new Tenent(); var userid = Guid.NewGuid(); var user = new User(); var contact = new Contact(); var dtocontact = new DtoContact(); _tenentRepo.Setup(x => x.GetById(tenentid)).ReturnsAsync(tenent); _userRepo.Setup(x => x.GetById(userid)).ReturnsAsync(user); _userRepo.Setup(x => x.FirstOrDefault(x => x.Tenent.Id == tenentid && x.Id == userid)).ReturnsAsync(user); _contactRepo.Setup(x => x.Add(contact)); var result = await _contactController.PostContact(dtocontact, tenentid, userid); var okresult = result as OkObjectResult; Assert.Equal(StatusCodes.Status200OK, okresult.StatusCode); }
public async Task PutUser_ShouldReturnOK() { var tenentid = Guid.NewGuid(); var userid = Guid.NewGuid(); var user = new User(); var dtouser = new DtoUser(); var tenent = new Tenent(); _tenentRepo.Setup(x => x.GetById(tenentid)).ReturnsAsync(tenent); _userRepo.Setup(x => x.GetById(userid)).ReturnsAsync(user); _userRepo.Setup(x => x.FirstOrDefault(x => x.Id == userid && x.Tenent.Id == tenentid)).ReturnsAsync(user); _userRepo.Setup(x => x.update(user)); var result = await _userController.UpdateUser(tenentid, userid, dtouser); var okresult = result as OkObjectResult; Assert.Equal(StatusCodes.Status200OK, okresult.StatusCode); }
public async Task GetContactOfUser_ShouldReturnContactList() { var tenentid = Guid.NewGuid(); var userid = Guid.NewGuid(); var contactid = Guid.NewGuid(); var tenent = new Tenent(); var user = new User(); var contact = new Contact(); var dtocontact = new DtoContact(); List <Contact> contacts = new List <Contact>(); _tenentRepo.Setup(x => x.GetById(tenentid)).ReturnsAsync(tenent); _userRepo.Setup(x => x.GetById(userid)).ReturnsAsync(user); _contactRepo.Setup(x => x.GetListBasedOnCondition(y => y.User.Tenent.Id == tenentid && y.User.Id == userid)).ReturnsAsync(contacts); var result = await _contactController.GetAllContact(tenentid, userid); Assert.Equal(contacts, result.Value); }
public async Task PutContact_ShouldReturnOk() { var tenentid = Guid.NewGuid(); var userid = Guid.NewGuid(); var contactid = Guid.NewGuid(); var tenent = new Tenent(); var user = new User(); var contact = new Contact(); var dtocontact = new DtoContact(); _tenentRepo.Setup(x => x.GetById(tenentid)).ReturnsAsync(tenent); _userRepo.Setup(x => x.GetById(userid)).ReturnsAsync(user); _contactRepo.Setup(x => x.GetById(contactid)).ReturnsAsync(contact); _contactRepo.Setup(x => x.FirstOrDefault(y => y.Id == contactid && y.User.Id == userid)).ReturnsAsync(contact); _contactRepo.Setup(x => x.update(contact)); var result = await _contactController.UpdateContact(tenentid, userid, contactid, dtocontact); var okresult = result as OkObjectResult; Assert.Equal(StatusCodes.Status200OK, okresult.StatusCode); }
public ResultMsg Edit(Guid TblId, Tenent Tbl) { throw new NotImplementedException(); }
public ResultMsg Create(Tenent Tbl) { return(crud.Create(Tbl)); }