public UnitOfWork() { _context = new ModelContainer(); Media = new MediaRepository(_context); Persons = new PersonsRepository(_context); Events = new EventsRepository(_context); Tags = new TagsRepository(_context); }
public bool UpdatePerson(PersonModel person) { if (PersonsRepository.Update(Core.Transformer.AsDatabaseModel(person)) != null) { return(true); } return(false); }
internal UnitOfWork(KatSystemDbContext context) { this.context = context; Users = new UsersRepository(context); Vehicles = new VehiclesRepository(context); Persons = new PersonsRepository(context); Fines = new FinesRepository(context); }
public bool DeletePerson(long id) { if (!PersonsRepository.PersonExists(id)) { return(false); } PersonsRepository.DeletePerson(id); return(true); }
public CodeCamperUnitOfWork(string nameOrConnectionString = "CodeCamper") : base(new CodeCamperDbContext(nameOrConnectionString)) { RoomsRepository = new EntityFrameworkReadRepository<Room>(DbContext); TimeSlotsRepository = new EntityFrameworkReadRepository<TimeSlot>(DbContext); TracksRepository = new EntityFrameworkReadRepository<Track>(DbContext); PersonsRepository = new PersonsRepository(DbContext); SessionsRepository = new SessionsRepository(DbContext); AttendanceRepository = new AttendanceRepository(DbContext); }
public void Delete_CallsContextDelete_WhenCalled( [NotNull, Frozen] IPersonsContext context, [NotNull] PersonsRepository sut) { // Arrange // Act sut.Delete(-1); // Assert context.Received().Delete(-1); }
public void Setup() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; _context = new ApplicationDbContext(options); _repos = new PersonsRepository <PersonsModel>(_context, _mapper); _service = new PersonsService(_context, _mapper, _repos); PrefillRepo(); }
public HttpResponseMessage UpdatePerson([FromUri] int id, [FromBody] ActualizarPersonaRequest request) { var alumno = PersonsRepository.ConsultarPersonaByID(id); if (alumno == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } PersonsRepository.ActualizarPersona(id, request.Nombre, request.idRol); return(Request.CreateResponse(HttpStatusCode.OK)); }
public void All_CallsContextPersons_WhenCalled( [NotNull, Frozen] IPersonsContext context, [NotNull] PersonsRepository sut) { // Arrange // Act // ReSharper disable once UnusedVariable IQueryable <IPerson> actual = sut.All; // Assert context.Received().Persons(); }
public void TestMethod2() { var repository = new PersonsRepository(connectionString); var result = repository.LoadPagedAll("cl", 0, 5, "FirstName", "ASC"); Assert.IsNotNull(result); Console.WriteLine($"{result.Count}"); foreach (var person in result.Items) { Console.WriteLine($"{person.FirstName} {person.LastName}"); } }
public WorksService( WorksRepository worksRepository, MarksRepository marksRepository, WorkTypesRepository workTypesRepository, PersonsRepository personsRepository, IMemoryCache memoryCache) { _worksRepository = worksRepository; _marksRepository = marksRepository; _workTypesRepository = workTypesRepository; _personsRepository = personsRepository; _memoryCache = memoryCache; }
public HttpResponseMessage GetPersons() { try { var listaPersons = PersonsRepository.ConsultarPersonas(); return(Request.CreateResponse(HttpStatusCode.OK, listaPersons)); } catch (Exception e) { Console.WriteLine($"An Exception has been caught: {e.Message}"); return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }
public void Delete_ReturnsPerson_WhenCalled( [NotNull] IPerson person, [NotNull, Frozen] IPersonsContext context, [NotNull] PersonsRepository sut) { // Arrange context.Delete(Arg.Any <int>()).Returns(person); // Act IPerson actual = sut.Delete(-1); // Assert Assert.Equal(person, actual); }
public bool DeletePerson(int personID) { try { var updatePerson = PersonsRepository.Get().Where(m => m.Id == personID).FirstOrDefault(); updatePerson.IsDeleted = true; if (PersonsRepository.Update(updatePerson) != null) { return(true); } return(false); }catch (Exception ex) { throw new Exception(ex.Message); } }
public void All_ReturnsPersons_WhenCalled( [NotNull, Frozen] IPersonsContext context, [NotNull] PersonsRepository sut) { // Arrange context.Persons().Returns(CreatePersons); // Act // ReSharper disable once UnusedVariable IQueryable <IPerson> actual = sut.All; // Assert Assert.Equal(2, actual.Count()); }
public void AssignId_test() { //Arrange const int expectedId = 1; PersonsRepository persons = new PersonsRepository(); //Act PrivateObject privateObject = new PrivateObject(persons); var id = privateObject.Invoke("AssignId"); //Assert Assert.AreEqual(expectedId, id); }
public bool InsertPerson(Persons entity) { try { bool isSuccess; using (var repo = new PersonsRepository()) { isSuccess = repo.Insert(entity); } return(isSuccess); } catch (Exception ex) { LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true); throw new Exception("BusinessLogic:PersonsBusiness::InsertPerson::Error occured.", ex); } }
public bool DeletePersonById(int empId) { try { using (var repository = new PersonsRepository()) { return(repository.DeleteById(empId)); } } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:PersonsBusiness::DeletePersonById::Error occured.", ex); } }
public bool DeletePersonById(int ID) { try { bool isSuccess; using (var repo = new PersonsRepository()) { isSuccess = repo.DeletedById(ID); } return(isSuccess); } catch (Exception ex) { LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true); throw new Exception("BusinessLogic:PersonsBusiness::DeletePerson::Error occured.", ex); } }
public HttpResponseMessage GetPersonByID(int id) { try { var persona = PersonsRepository.ConsultarPersonaByID(id); if (persona == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, persona)); } catch (Exception e) { Console.WriteLine($"An Exception has been caught: {e.Message}"); return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }
public bool AddPerson(PersonModel person) { try { var addPerson = PersonsRepository.Add(Core.Transformer.AsDatabaseModel(person)); if (addPerson != null) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void TestPersonsRepositoryCRUDMethods() { bool CreateProfile; bool ReadProfile; bool UpdateProfile; bool DeleteProfile; var personsRepository = new PersonsRepository(); var addProfileModel = new AddProfileModel { FirstName = "test", LastName = "test", Patronymic = "test", PhoneNumber = "test" }; var addedProfileId = personsRepository.AddProfile(addProfileModel); CreateProfile = addedProfileId > 0 ? true : false; var profile = personsRepository.GetProfile(addedProfileId); ReadProfile = !string.IsNullOrEmpty(profile?.FirstName) ? true : false; var updateProfileModel = new UpdateProfileModel { Id = addedProfileId, FirstName = "testUpdated", LastName = "testUpdated", Patronymic = "testUpdated", PhoneNumber = "testUpdated" }; UpdateProfile = personsRepository.UpdateProfile(updateProfileModel); personsRepository.DeleteProfile(addedProfileId); DeleteProfile = true; Assert.IsTrue(CreateProfile && ReadProfile && UpdateProfile && DeleteProfile); }
public bool UpdatePerson(PersonsEntity entity) { try { bool bOpDoneSuccessfully; using (var repository = new PersonsRepository()) { bOpDoneSuccessfully = repository.Update(entity); } return(bOpDoneSuccessfully); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:PersonsBusiness::UpdatePerson::Error occured.", ex); } }
public PersonsEntity SelectPersonById(int personId) { try { PersonsEntity returnedEntity; using (var repository = new PersonsRepository()) { returnedEntity = repository.SelectById(personId); } return(returnedEntity); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:PersonsBusiness::SelectPersonById::Error occured.", ex); } }
public Persons SelectPersonById(int personId) { try { Persons responseEntitiy; using (var repo = new PersonsRepository()) { responseEntitiy = repo.SelectedById(personId); if (responseEntitiy == null) { throw new NullReferenceException("Person doesnt exists!"); } } return(responseEntitiy); } catch (Exception ex) { LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true); throw new Exception("BusinessLogic:PersonsBusiness::SelectPersonById::Error occured.", ex); } }
public List <Persons> SelectAllPersons() { var responseEntities = new List <Persons>(); try { using (var repo = new PersonsRepository()) { foreach (var entity in repo.SelectAll()) { responseEntities.Add(entity); } } return(responseEntities); } catch (Exception ex) { LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true); throw new Exception("BusinessLogic:PersonsBusiness::SelectAllPersons::Error occured.", ex); } }
public void TestGetProfilesMethod() { bool Success; var personsRepository = new PersonsRepository(); var addProfileModel = new AddProfileModel { FirstName = "test", LastName = "test", Patronymic = "test", PhoneNumber = "test" }; var addedProfileId = personsRepository.AddProfile(addProfileModel); var profilesList = personsRepository.GetProfiles(); Success = profilesList.Count > 0 ? true : false; personsRepository.DeleteProfile(addedProfileId); Assert.IsTrue(Success); }
public List <PersonsEntity> SelectAllPersons() { var returnedEntities = new List <PersonsEntity>(); try { using (var repository = new PersonsRepository()) { foreach (var entity in repository.SelectAll()) { returnedEntities.Add(entity); } } return(returnedEntities); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:PersonsBusiness::SelectAllPersons::Error occured.", ex); } }
//Constructor that receives the PersonsDatabaseAccess variable public PersonsController(PersonsDatabaseAccess db) { personRepository = new PersonsRepository(db); }
public HttpResponseMessage DeleteAlumno(int id) { PersonsRepository.EliminarPersona(id); return(Request.CreateResponse(HttpStatusCode.OK)); }
public HttpResponseMessage CreatePerson([FromBody] CrearPersonaRequest request) { var persona = PersonsRepository.InsertarPersona(request.Nombre, request.idRol); return(Request.CreateResponse(HttpStatusCode.OK, persona)); }