public static Result add(School school) { using (SGContext db = new SGContext()) { try { var repo = new Repository<School>(db); var sch = repo.Find(d => d.Ad == school.Ad && d.IsDeleted == false); var schmeb = repo.Find(d => d.MebKodu == school.MebKodu && d.IsDeleted == false); if (sch.Count() > 0) { result = new Result(SystemRess.Messages.hata_ayniOkulSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString()); return result; } else if (schmeb.Count() > 0) { result = new Result(SystemRess.Messages.hata_ayniMebKoduSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString()); return result; } repo.Add(school); result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString()); return result; } catch (Exception) { result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString()); return result; } } }
public void Should_Save_a_Job() { var fixture = new Fixture(); var job = fixture.Build<Job>() .Without(c => c.Id) .CreateAnonymous(); using (var saveContext = DbContext()) { var repo = new Repository<Job>(saveContext); repo.InsertOrUpdate(job); repo.Save(); } Job savedJob; using (var readContext = DbContext()) { var repo1 = new Repository<Job>(readContext); savedJob = repo1.Find(job.Id); } // savedJob.Id.ShouldEqual(1); var compare = new KellermanSoftware.CompareNetObjects.CompareObjects(); // savedJob is a proxy compare.MaxDifferences = 1; compare.Compare(job, savedJob); (compare.Differences.Count <= 1).ShouldBeTrue(); Debug.WriteLine(compare.DifferencesString); }
public static User Login(Int64 tckimlikno, string password) { using (SGContext db = new SGContext()) { var userRepository = new Repository<User>(db); var us = userRepository.Find(d => d.TCKimlik == tckimlikno && d.Sifre == password); if (us.Count() > 0) { User record = new User(); SG_DAL.Enums.EnumRol rol = (SG_DAL.Enums.EnumRol)(us.FirstOrDefault().Rol); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, us.FirstOrDefault().Ad + " " + us.FirstOrDefault().Soyad, DateTime.Now, DateTime.Now.AddMinutes(120), false, rol.ToString(), FormsAuthentication.FormsCookiePath); string encTicket = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); if (ticket.IsPersistent) cookie.Expires = ticket.Expiration; HttpContext.Current.Response.Cookies.Add(cookie); HttpCookie myCookie = new HttpCookie("LoginCookie"); myCookie["tcno"] = us.FirstOrDefault().TCKimlik.ToString(); myCookie.Expires = DateTime.Now.AddDays(1d); HttpContext.Current.Response.Cookies.Add(myCookie); return us.FirstOrDefault(); } else return null; } }
public static Result CreateUser(User newUser) { using (SGContext db = new SGContext()) { try { var userRepository = new Repository<User>(db); var user = userRepository.Find(d => d.TCKimlik == newUser.TCKimlik); if (user.Count() < 1) { if (string.IsNullOrEmpty(newUser.Sifre)) { newUser.Sifre = newUser.TCKimlik.ToString(); } userRepository.Add(newUser); result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString()); return result; } else { result = new Result(SystemRess.Messages.hata_ayniTcSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString()); return result; } } catch (Exception) { result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString()); return result; } } }
static void Main(string[] args) { var context = new DataContext("Data Source=(local);Initial Catalog=GettingStarted;Integrated Security=true;", new GettingStartedMappings()); var repository = new Repository(context); IEnumerable<Person> results = repository.Find(new FindPersonByLastNameEmbeddedSQLQuery("Liles")); }
public void Integration_LogDataContext_LogResository_Log_Find_Return_Log() { Logqso.mvc.Entities.LogDataEntity.Log Log1 = null; // context object LogDataContext matches the same name used for LogqsoData DB using (IDataContextAsync context = new ContestqsoDataContext()) //IUnitOfWorkDataAsync and UnitOfWorkData are used in order for Dependency Injection to inject the DataDB using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { bool caught = false; IRepositoryAsync<Logqso.mvc.Entities.LogDataEntity.Log> _logRepository = new Repository<Log>(context, unitOfWork); try { Log1 = _logRepository.Find(LogId); } catch (Exception ex) { TestContext.WriteLine(string.Format("Integration_LogDataContext_LogResository_Log_Find_Return_Log exception {0}",ex.Message) ); caught = true; } Assert.IsFalse(caught); //exception Assert.IsNotNull(Log1); Assert.IsInstanceOfType(Log1, typeof(Logqso.mvc.Entities.LogDataEntity.Log)); Assert.AreEqual( LogId, Log1.LogId ); Assert.IsInstanceOfType(Log1.ContestYear, typeof(DateTime)); Assert.AreEqual(1, Log1.CallsignId ); } }
public void Delete(string slug) { using (var repository = new Repository<Entry>()) { var entry = repository.Find(slug); repository.Delete(entry); } }
public void Find_WithCriteria_ThrowsNotImplementedException(Mock<IUnitOfWork> unitOfWork) { // Given var sut = new Repository<object>(unitOfWork.Object); // Then Assert.Throws<NotImplementedException>(() => sut.Find(i => true)); }
public void Should_return_correct_number_of_records_based_on_criteria() { using (var context = new RepositoryTestDataContext()) { var repo = new Repository<Order>(context); Assert.AreEqual(3, repo.Find(o => o.CustomerID == "VINET").Count()); } }
public void Should_return_empty_enumerable_where_no_records_match_criteria() { using (var context = new RepositoryTestDataContext()) { var repo = new Repository<Order>(context); CollectionAssert.IsEmpty(repo.Find(o => o.CustomerID == "NoMatch")); } }
public void Should_throw_exception_if_null_criteria_provided() { using (var context = new RepositoryTestDataContext()) { var repo = new Repository<Order>(context); Assert.Throws<ArgumentNullException>(() => repo.Find(null)); } }
public void Simple_Map_Test() { UnitOfWork unitOfWork = new UnitOfWork(NHibernateHelper.SessionFactory); Repository repo = new Repository(unitOfWork.Session); UserProfile userProfile = repo.Find<UserProfile>(m => m.Name.Equals("brunod")).FirstOrDefault(); Assert.AreEqual("*****@*****.**", userProfile.Email); unitOfWork.Rollback(); unitOfWork.Dispose(); }
public int GetCostsCount(int costCenterId) { int count; using (var context = new SoheilEdmContext()) { var repository = new Repository<Cost>(context); count = repository.Find(item=>item.CostCenter != null && item.CostCenter.Id == costCenterId).Count(); } return count; }
public void ShouldApplyPaging() { var uri = new Uri("http://localhost/Something/To/Test?$inlinecount=allpages&$skip=1&$top=1"); var context = GetTestContext(); var repo = new Repository(context); var odataResponse = repo.Find(new GetByOData<ExampleLeaf>(HttpUtility.ParseQueryString(uri.Query))); odataResponse.Count.Should().Be(3); odataResponse.Results.Should().HaveCount(1); }
public void SourceDataTypeMap_TufmanFM_GearPS_ReturnsLogsheetDataType() { UnitOfWork unitOfWork = new UnitOfWork(NHibernateHelper.SessionFactory); Repository repo = new Repository(unitOfWork.Session); List<SourceDataType> sourceDataTypes = repo.Find<SourceDataType>(x => x.Gear.Code == "S" && x.Source.Id == 12).ToList(); repo.GetAll<Gear>(); Assert.IsNotNull(sourceDataTypes); Assert.IsTrue(sourceDataTypes.Count == 1); Assert.IsTrue(sourceDataTypes[0].DataType.Id==1); }
public void TestMethod1() { var context = new Repository(new AdventureWorksContext(Settings.Default.Connection)); var query = context.Find<Product>().FilterByColor("Blue"); Console.WriteLine(((DbQuery<Product>)query).ToString()); }
public void Find_DoesNotReturnNull(Mock<IUnitOfWork> unitOfWork, object[] entities) { // Given unitOfWork.Setup(s => s.Get<object>()).Returns(entities); var sut = new Repository<object>(unitOfWork.Object); // When var result = sut.Find(); // Then Assert.NotNull(result); }
public void When_Passing_To_A_Repository_Query_Object_Then_It_Executes_Against_Context() { //Arrange var context = MockRepository.GenerateStrictMock<IDataContext>(); context.Expect(x => x.AsQueryable<Foo>()).Return(new List<Foo>().AsQueryable()).Repeat.Once(); var repository = new Repository(context); //Act repository.Find(new FindFoo()); //Assert context.VerifyAllExpectations(); }
public void ShouldVerifyRepository() { var resume = new Resume {Summary = Guid.NewGuid().ToString()}; var repository = new Repository(); Assert.IsTrue(repository.Save(resume)); var result = repository.Find<Resume>(); Assert.IsNotNull(result); Assert.AreEqual(resume.Summary, result.Summary); }
public void Find_WithEagerLoadedPropertyPaths_InvokesUnitOfWorkWithSamePath( Mock<IUnitOfWork> unitOfWork, string[] propertyPaths) { // Given var sut = new Repository<object>(unitOfWork.Object); // When sut.Find(propertyPaths); // Then unitOfWork.Verify(m => m.Get<object>(propertyPaths)); }
private static void consultasSimples() { var endRep = new Repository<Endereco>(); var munRep = new Repository<Municipio>(); var ufRep = new Repository<UnidadeFederacao>(); var sp = ufRep.Find(e => e.Id == 35); var endereco = endRep.Get(1); endereco.Municipio = munRep.Get(endereco.MunicipioID); endereco.Municipio.UF = ufRep.Get(endereco.Municipio.UnidadeFederacaoID); var estados = ufRep.Collection(e => e.Sigla.Contains("S")); }
public void Test_Get() { using (var cluster = new Cluster()) { using (var bucket = cluster.OpenBucket("beer-sample")) { var breweryRepository = new Repository<Couchbase.Data.RepositoryExample.Models.Brewery>(bucket); var brewery = breweryRepository.Find("21st_amendment_brewery_cafe"); var document = brewery.Content; breweryRepository.Save(brewery); } } }
static void Main(string[] args) { string connString = "your connection string"; using (var dataContext = new MyContext(connString)) { var userRepository = new Repository<User>(dataContext); User user = userRepository .Find(c => c.Nombre.StartsWith("Rob")); Console.WriteLine("Nombre del usuario: {0} *", user.Nombre); Console.ReadKey(); } }
public void Join_example_with_transaction_insert() { Repository.DefaultConnectionString = @"Data source=.\SQLEXPRESS;Initial Catalog=WeenyMapper;Trusted_Connection=true"; Repository.DefaultConvention = new BlogConvention(); var myBlog = new Blog("My blog"); var steve = new User("Steve", "password"); var post1 = new BlogPost("Title 1", "Content 1 goes here") { Blog = myBlog, Author = steve }; var post2 = new BlogPost("Title 2", "Content 2 goes here") { Blog = myBlog, Author = steve }; var post3 = new BlogPost("Title 3", "Content 3 goes here") { Blog = myBlog, Author = steve }; var post4 = new BlogPost("Title 4", "Content 4 goes here") { Blog = myBlog, Author = steve }; using (var repository = new Repository()) { using (var transaction = repository.BeginTransaction()) { repository.Insert(myBlog); repository.Insert(steve); repository.Insert(post1, post2, post3, post4); transaction.Commit(); } repository.Update<BlogPost>() .Set(x => x.Title, "Updated title 2") .Where(x => x.Id == post2.Id) .Execute(); repository.Delete<BlogPost>() .Where(x => x.Id == post3.Id || x.Title == "Title 4") .Execute(); var actualBlog = repository.Find<Blog>().Where(x => x.Id == myBlog.Id) .Join(x => x.Posts, x => x.Blog) .OrderBy<BlogPost>(x => x.Title) .Execute(); Assert.AreEqual("My blog", actualBlog.Name); Assert.AreEqual(2, actualBlog.Posts.Count); Assert.AreEqual("Title 1", actualBlog.Posts[0].Title); Assert.AreEqual("Updated title 2", actualBlog.Posts[1].Title); } }
public void DatabaseAccess() { try { using(var db = new WeddingDb()) { Repository<Group> repository = new Repository<Group>(db); var t = repository.Find(m => m.Id == 3).FirstOrDefault(); repository.Delete(t); //var list = d } } catch (Exception ex) { } }
public void AddNews_ValidNewsAddedToDb_ShouldReturnNews() { // Arrange -> prapare the objects var newValidNews = new News { Title = "Valid news added", Content = "Something", PublishDate = DateTime.Now }; IRepository<News> repository = new Repository<News>(); // Act -> perform some logic repository.Add(newValidNews); repository.SaveChanges(); // Assert -> validate the results var newsFromDb = repository.Find(newValidNews.Id); Assert.IsNotNull(newsFromDb); Assert.AreEqual(newValidNews.Title, newsFromDb.Title); Assert.AreEqual(newValidNews.Content, newsFromDb.Content); Assert.AreEqual(newValidNews.PublishDate, newsFromDb.PublishDate); Assert.IsTrue(newsFromDb.Id != 0); }
public static Result addTeacher(User newUser, Teacher teacher) { using (SGContext db = new SGContext()) { try { var userRepository = new Repository<User>(db); var user = userRepository.Find(d => d.TCKimlik == newUser.TCKimlik); if (user.Count() > 0) { result = new Result(SystemRess.Messages.hata_ayniTcSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString()); return result; } else if (string.IsNullOrEmpty(newUser.Sifre)) { newUser.Sifre = newUser.TCKimlik.ToString(); } var okulRepo = new Repository<School>(db); int okulID = teacher.Okul.SchoolId; var okul = okulRepo.Find(d => d.SchoolId == okulID); teacher.Okul = okul.First(); if (teacher.Unvan == 1) newUser.Rol = (int)SG_DAL.Enums.EnumRol.ogretmen; else if (teacher.Unvan == 2 || teacher.Unvan == 3) newUser.Rol = (int)SG_DAL.Enums.EnumRol.idareci; teacher.User = newUser; teacher.GorevSayisi = 0; var teacherRepo = new Repository<Teacher>(db); teacherRepo.Add(teacher); result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString()); return result; } catch (Exception) { result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString()); return result; } } }
public void In_query_example() { CreateBlogTestData(); using (var repository = new Repository()) { var postTitles = new[] { "Title 1", "Title 3", "Title 4" }; var posts = repository.Find<BlogPost>() .Where(x => postTitles.Contains(x.Title)) .OrderBy<BlogPost>(x => x.Title) .ExecuteList(); Assert.AreEqual(3, posts.Count); Assert.AreEqual("Title 1", posts[0].Title); Assert.AreEqual("Title 3", posts[1].Title); Assert.AreEqual("Title 4", posts[2].Title); } }
static void Main(string[] args) { var context = new DataContext("Data Source=(local);Initial Catalog=GettingStarted;Integrated Security=true;", new GettingStartedMappings()); var repository = new Repository(context); //Adding Items repository.Context.Add(new Person() { FirstName = "Devlin", LastName = "Liles" }); repository.Context.Add(new Person() { FirstName = "Tim", LastName = "Rayburn" }); repository.Context.Add(new Person() { FirstName = "Jay", LastName = "Smith" }); repository.Context.Add(new Person() { FirstName = "Brian", LastName = "Sullivan" }); repository.Context.Commit(); var criteria = Criteria.Field<DateTime>("BirthDate").On(new DateTime(2012,1,1)); IEnumerable<Person> results = repository.Find(new FindByCriteria<Person>(criteria)); var person = results.First(); var secondResults = results.Where("FirstName = @0", "Devlin"); }
static void Main(string[] args) { //Setup var context = new DataContext("Data Source=(local);Initial Catalog=GettingStarted;Integrated Security=true;",new GettingStartedMappings()); var repository = new Repository(context); //Adding Items repository.Context.Add(new Person() {FirstName = "Devlin", LastName = "Liles"}); repository.Context.Add(new Person() { FirstName = "Tim", LastName = "Rayburn" }); repository.Context.Add(new Person() { FirstName = "Jay", LastName = "Smith" }); repository.Context.Add(new Person() { FirstName = "Brian", LastName = "Sullivan" }); repository.Context.Commit(); IEnumerable<Person> results = repository.Find(new FindPersonByLastName("Rayburn")); var person = results.First(); person.LastName = "SillyRayburn"; //HEHEHE - He is not going to like this. repository.Context.Commit(); repository.Get(new GetPersonByFirstAndLastName("Devlin", "Liles")); repository.Execute(new ChangeStatusOnAllPeople(3)); }
/// <summary> /// Search the repository, not exposed to clients since accessor is protected /// </summary> /// <param name="expression"></param> /// <returns></returns> protected virtual IEnumerable <TV> Find(Func <TV, bool> expression) { return(Repository <Guid, TV> .Find(expression)); }
/// <summary> /// Gets a collection of <see cref="Rock.Model.ExceptionLog"/> entities by the Id of their Parent exceptionId. /// Under most instances, only one child <see cref="Rock.Model.ExceptionLog"/> entity will be returned in the collection. /// </summary> /// <param name="parentId">An <see cref="System.Int32"/> containing the Id of the parent ExceptionLog entity to search by.</param> /// <returns>An enumerable collection of <see cref="Rock.Model.ExceptionLog" /> entities who's Parent ExceptionId matches the provided value..</returns> public IEnumerable <ExceptionLog> GetByParentId(int?parentId) { return(Repository.Find(t => (t.ParentId == parentId || (parentId == null && t.ParentId == null)))); }
/// <summary> /// Returns an enumerable collection of <see cref="Rock.Model.GroupType"/> entities by the Id of their <see cref="Rock.Model.GroupTypeRole"/>. /// </summary> /// <param name="defaultGroupRoleId">An <see cref="System.Int32"/> representing the Id of the <see cref="Rock.Model.GroupTypeRole"/> to search by.</param> /// <returns>An enumerable collection of <see cref="Rock.Model.GroupType">GroupTypes</see> that use the provided <see cref="Rock.Model.GroupTypeRole"/> as the /// default GroupRole for their member Groups.</returns> public IEnumerable <GroupType> GetByDefaultGroupRoleId(int?defaultGroupRoleId) { return(Repository.Find(t => (t.DefaultGroupRoleId == defaultGroupRoleId || (defaultGroupRoleId == null && t.DefaultGroupRoleId == null)))); }
/// <summary> /// Gets an enumerable list of <see cref="Rock.Model.PageRoute"/> entities that are linked to a <see cref="Rock.Model.Page"/> by the /// by the <see cref="Rock.Model.Page">Page's</see> Id. /// </summary> /// <param name="pageId">An <see cref="System.Int32"/> value containing the Id of the <see cref="Rock.Model.Page"/> .</param> /// <returns>An enumerable collection of <see cref="Rock.Model.PageRoute"/> entities that reference the supplied PageId.</returns> public IEnumerable <PageRoute> GetByPageId(int pageId) { return(Repository.Find(t => t.PageId == pageId)); }
public SubmitResult SetViewParams(ViewParamsSetter setter) { var ps = new List <Page>(); if (setter.PageName != null) { ps = Repository.Find(d => d.TenantId == setter.TenantId && d.Name == setter.PageName); } else if (setter.TemplateName != null) { ps = Repository.Find(d => d.TenantId == setter.TenantId && d.PageCategory.Name == setter.TemplateName); } else { throw new ArgumentException("PageName or TemplateName must be provided"); } if (!ps.Any()) { throw new ArgumentOutOfRangeException("not found"); } foreach (var p in ps) { var vp = new ViewParams(); if (p.ViewParams != null) { vp = p.ViewParams.FromJson <ViewParams>(); } if (vp.Other == null) { vp.Other = new Dictionary <string, string>(); } if (setter.Fields != null) { vp.Fields = setter.Fields; } foreach (var kv in setter.Data) { if (kv.Key.ToLower().StartsWith("other.")) { string key = kv.Key.GetAfterFirst("."); if (kv.Value.ToLower() == "default") { vp.Other.Remove(key); } else { vp.Other[key] = kv.Value; } } else { var prop = typeof(ViewParams).GetProperty(kv.Key); if (prop != null) { prop.SetValue(vp, kv.Value); } } } p.ViewParams = vp.ToJson(); } return(Unit.SaveChanges()); }
public virtual List <User> GetUsersByRoleId(long Roleid) { var xx = Unit.UserRoleRepository.Find(x => x.RoleId == Roleid); return(Repository.Find(x => xx.Any(y => y.UserId == x.Id))?.ToList() ?? new List <User>()); }
/// <summary> /// 根据key ,firstId,secondId获取thirdId /// </summary> /// <param name="key"></param> /// <param name="firstId"></param> /// <param name="secondId"></param> /// <returns></returns> public List <string> Get(string key, string firstId, string secondId) { return(Repository.Find(u => u.Key == key && u.FirstId == firstId && u.SecondId == secondId) .Select(u => u.ThirdId).ToList()); }
public List<Dict> GetAllDictList() { var dictPoList = Repository.Find(d => d.VALID == 1).ToList(); return Mapper.Map<List<DictionaryPO>, List<Dict>>(dictPoList); }
/// <summary> /// Gets Person Vieweds by Viewer Person Id /// </summary> /// <param name="viewerPersonId">Viewer Person Id.</param> /// <returns>An enumerable list of PersonViewed objects.</returns> public IEnumerable <PersonViewed> GetByViewerPersonId(int?viewerPersonId) { return(Repository.Find(t => (t.ViewerPersonId == viewerPersonId || (viewerPersonId == null && t.ViewerPersonId == null)))); }
public TypeOfRegion Get(string name, params Expression <Func <TypeOfRegion, object> >[] includePaths) { return(Repository.Find(typeOfRegion => typeOfRegion.Name == name, includePaths)); }
public ActionResult CostsByDepartments(Guid?DepartmentGUID, Guid?ProjectGUID) { ChartData <SingleColorChartDataset <int> > chartData = new ChartData <SingleColorChartDataset <int> >(); if (DepartmentGUID == null && ProjectGUID == null) { List <Department> departments = (from d in DptRepo.GetCollections() join p in ProjectRepo.GetCollections() on d.DepartmentGUID equals p.RequiredDeptGUID select d).Distinct().ToList(); chartData.labels = departments.Select(d => d.DepartmentName).ToList(); chartData.datasets.Add(new SingleColorChartDataset <int> { type = "line", label = "累計費用", backgroundColor = "#d9006c", borderColor = "#d9006c", data = departments.GetCostsByDepartment() }); chartData.datasets.Add(new SingleColorChartDataset <int> { label = "總專案預算", backgroundColor = "rgba(91, 155, 213, 0.5)", borderColor = "rgba(91, 155, 213, 1)", data = departments.GetBudgetsByDepartment() }); } else if (ProjectGUID != null) { Project project = ProjectRepo.Find(ProjectGUID); List <int> months = new List <int>(); for (int i = 2; i >= 0; i--) { if (DateTime.Now.Month - i <= 0) { months.Add(DateTime.Now.Month + 12 - i); } else { months.Add(DateTime.Now.Month - i); } } List <string> chtmonths = months.GetChineseMonths().ToList(); chartData.labels = chtmonths; chartData.datasets.Add(new SingleColorChartDataset <int> { label = "當月費用", backgroundColor = "#90C3D4", borderColor = "#90C3D4", data = project.GetCostsByMonths(months) }); } else { List <Project> projects = ProjectRepo.GetCollections().Where(p => p.RequiredDeptGUID == DepartmentGUID).ToList(); chartData.labels = projects.Select(p => p.ProjectName).ToList(); chartData.datasets.Add(new SingleColorChartDataset <int> { type = "line", label = "累計費用", backgroundColor = "#d9006c", borderColor = "#d9006c", data = projects.GetCostsByProjects() }); chartData.datasets.Add(new SingleColorChartDataset <int> { label = "專案預算", backgroundColor = "rgba(91, 155, 213, 0.5)", borderColor = "rgba(91, 155, 213, 1)", data = projects.GetBudgetsByProject() }); } return(Content(JsonConvert.SerializeObject(chartData), "application/json")); }
public T Find(Expression <Func <T, bool> > where) { return(BLLrepository.Find(where)); }
public bool CrearCompra(Cliente arg, DateTime fecha, string NumFacura, List <PurchasesBLL> detalle, decimal?flete) { bool Resul = true; Cliente cliente; using (var resp = new Repository <Cliente>()) { cliente = resp.Find(x => x.Cedula == arg.Cedula); if (cliente == null) { var row = resp.GetAll().Count; row++; arg.IDCliente = row; cliente = resp.Create(arg); } if (cliente == null) { Resul = false; error = resp.Error; } } Factura factura = null; if (Resul) { using (var resp = new Repository <Factura>()) { var row = resp.GetAll().Count; row++; factura = resp.Create(new Factura { IDFactura = row, IDCliente = cliente.IDCliente, Numero = NumFacura, Fecha = fecha, Estado = "A", IDTerminal = Convert.ToInt16(General.Terminal), FechaSistema = DateTime.Now, Flete = flete }); if (factura == null) { Resul = false; error = resp.Error; } } } ParametrosBLL p = new ParametrosBLL(); if (Resul) { //con iva foreach (PurchasesBLL d in detalle) { if (d.IDProducto != 0) { Repository <FacturaDetalle> de = new Repository <FacturaDetalle>(); if (d.UconIva > 0 && d.PUconIva > 0) { if (!de.SQLQuery <FacturaDetalle>("EXEC Sp_FacturaDetalleGrabar {0}, {1}, {2}, {3}, {4}, {5}", new object[] { d.IDProducto, d.PUconIva, d.UconIva, factura.IDFactura, "C", p.myIva })) { Resul = false; error = de.Error; break; } } if (d.UsinIva > 0 && d.PUsinIva > 0) { if (!de.SQLQuery <FacturaDetalle>("EXEC Sp_FacturaDetalleGrabar {0}, {1}, {2}, {3}, {4}, {5}", new object[] { d.IDProducto, d.PUconIva, d.UconIva, factura.IDFactura, "C", 0 })) { Resul = false; error = de.Error; break; } } } } } return(Resul); }
// <summary> // Gets Exception Logs by Person Id // </summary> // <param name="personId">Person Id.</param> // <returns>An enumerable list of ExceptionLog objects.</returns> //public IEnumerable<ExceptionLog> GetByPersonId( int? personId ) //{ // return Repository.Find( t => ( t.CreatedByPersonId == personId || ( personId == null && t.PersonId == null ) ) ); //} /// <summary> /// Gets a collection of <see cref="Rock.Model.ExceptionLog"/> entities by the Id of the <see cref="Rock.Model.Site"/> that they occurred on. /// </summary> /// <param name="siteId">An <see cref="System.Int32"/> containing the Id of the <see cref="Rock.Model.Site"/> to search by.</param> /// <returns>An enumerable collection of <see cref="Rock.Model.ExceptionLog"/> entities who's SiteId matches the provided value.</returns> public IEnumerable <ExceptionLog> GetBySiteId(int?siteId) { return(Repository.Find(t => (t.SiteId == siteId || (siteId == null && t.SiteId == null)))); }
public IEnumerable <Resource> Get(string type) { return(Repository.Find(u => u.TypeId == type)); }
public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request, Yupi.Protocol.IRouter router) { int roomId = request.GetInteger(); RoomData roomData = RoomRepository.Find(roomId); if (roomData == null || !roomData.HasOwnerRights(session.Info)) { return; } // TODO Filter string newName = request.GetString(); // TODO Magic constant if (newName.Length > 2) { roomData.Name = newName; } // TODO Filter roomData.Description = request.GetString(); int stateId = request.GetInteger(); RoomState state; if (RoomState.TryFromInt32(stateId, out state)) { roomData.State = state; } roomData.Password = request.GetString(); roomData.UsersMax = request.GetInteger(); int categoryId = request.GetInteger(); FlatNavigatorCategory category = NavigatorCategoryRepository.Find(categoryId); if (category != null && category.MinRank <= session.Info.Rank) { roomData.Category = category; } int tagCount = request.GetInteger(); if (tagCount <= 2) { roomData.Tags.Clear(); IRepository <Tag> TagRepository = DependencyFactory.Resolve <IRepository <Tag> > (); for (int i = 0; i < tagCount; i++) { string tagValue = request.GetString().ToLower(); Tag tag = TagRepository.Find(tagValue); if (tag == null) { tag = new Tag(tagValue); } roomData.Tags.Add(tag); } } TradingState tradeState; if (TradingState.TryFromInt32(request.GetInteger(), out tradeState)) { roomData.TradeState = tradeState; } roomData.AllowPets = request.GetBool(); roomData.AllowPetsEating = request.GetBool(); roomData.AllowWalkThrough = request.GetBool(); bool hideWall = request.GetBool(); int wallThickness = request.GetInteger(); int floorThickness = request.GetInteger(); if (session.Info.Subscription.HasLevel(ClubLevel.HC)) { roomData.HideWall = hideWall; roomData.WallThickness = wallThickness; roomData.FloorThickness = floorThickness; } else { roomData.HideWall = false; roomData.WallThickness = 0; roomData.FloorThickness = 0; } RoomModerationRight right; if (RoomModerationRight.TryFromInt32(request.GetInteger(), out right)) { roomData.ModerationSettings.WhoCanMute = right; } if (RoomModerationRight.TryFromInt32(request.GetInteger(), out right)) { roomData.ModerationSettings.WhoCanKick = right; } if (RoomModerationRight.TryFromInt32(request.GetInteger(), out right)) { roomData.ModerationSettings.WhoCanBan = right; } ChatType chatType; if (ChatType.TryFromInt32(request.GetInteger(), out chatType)) { roomData.Chat.Type = chatType; } ChatBalloon chatBalloon; if (ChatBalloon.TryFromInt32(request.GetInteger(), out chatBalloon)) { roomData.Chat.Balloon = chatBalloon; } ChatSpeed chatSpeed; if (ChatSpeed.TryFromInt32(request.GetInteger(), out chatSpeed)) { roomData.Chat.Speed = chatSpeed; } int maxDistance = request.GetInteger(); if (roomData.Chat.isValidDistance(maxDistance)) { roomData.Chat.SetMaxDistance(maxDistance); } FloodProtection floodProtection; if (FloodProtection.TryFromInt32(request.GetInteger(), out floodProtection)) { roomData.Chat.FloodProtection = floodProtection; } request.GetBool(); //TODO allow_dyncats_checkbox router.GetComposer <RoomSettingsSavedMessageComposer>().Compose(session, roomData.Id); Room room = RoomManager.GetIfLoaded(roomData); if (room != null) { room.EachUser(x => { x.Router.GetComposer <RoomUpdateMessageComposer>().Compose(x, roomData.Id); x.Router.GetComposer <RoomFloorWallLevelsMessageComposer>().Compose(x, roomData); x.Router.GetComposer <RoomChatOptionsMessageComposer>().Compose(x, roomData); x.Router.GetComposer <RoomDataMessageComposer>().Compose(x, roomData, x.Info, true, true); }); } }
public T Find(System.Linq.Expressions.Expression <Func <T, bool> > where) { //gelen nesneyi kosulla return(repo.Find(where)); }
/// <summary> /// Gets Person Vieweds by Target Person Id /// </summary> /// <param name="targetPersonId">Target Person Id.</param> /// <returns>An enumerable list of PersonViewed objects.</returns> public IEnumerable <PersonViewed> GetByTargetPersonId(int?targetPersonId) { return(Repository.Find(t => (t.TargetPersonId == targetPersonId || (targetPersonId == null && t.TargetPersonId == null)))); }
public UserData() { var DBUsers = Repository.Find <User>(x => true); Users = DBUsers.OrderBy(i => i.FirstName).ToList(); }
/// <summary> /// Gets Sites by Default Page Id /// </summary> /// <param name="defaultPageId">Default Page Id.</param> /// <returns>An enumerable list of Site objects.</returns> public IEnumerable <Site> GetByDefaultPageId(int?defaultPageId) { return(Repository.Find(t => (t.DefaultPageId == defaultPageId || (defaultPageId == null && t.DefaultPageId == null)))); }
public Organizations GetOrganization(int Organizationid) { return(repo.Find(x => x.OrganizationID == Organizationid)); }
/// <summary> /// Gets Metrics by Type /// </summary> /// <param name="type">The type.</param> /// <returns> /// An enumerable list of Metric objects. /// </returns> public IEnumerable <Metric> GetByType(bool?type) { return(Repository.Find(t => (t.Type == type || (type == null && t.Type == null))).OrderBy(t => t.Order)); }
public IActionResult IndexVoyageur() { var model = Repository.Find(v => v.Date >= DateTime.Now && !v.IsFull, false).OrderBy(v => v.Date); return(View("index", model)); }
/// <summary> /// 根据学员编号删除学员信息 /// </summary> /// <param name="userCode">学员编号</param> public bool DeleteById(int id) { bool res = true; try { Repository <student> studentModuleDal = _unitOfWork.GetRepository <student>(); Repository <class_record_detail> crdDal = _unitOfWork.GetRepository <class_record_detail>(); student studententity = studentModuleDal.GetObjectByKey(id).Entity; if (studententity != null) { if (studententity.student_recharge_detail.Count > 0) { throw new FaultException <LCFault>(new LCFault("删除学员失败"), "该学员已经参与过充值、上课等内容,无法删除"); } else { if (studententity.consultants != null && studententity.consultants.Count > 0) { //如果该学员设置了会籍顾问,需要先删除会籍顾问 studententity.consultants.Clear(); } if (studententity.classess != null && studententity.classess.Count > 0) { //如果给这个学员分配过班级,则先需要删除学员班级信息 studententity.classess.Clear(); } //删除未签到的上课记录 IEnumerable <class_record_detail> crds = crdDal.Find(cr => cr.student_id == studententity.student_id).Entities; foreach (class_record_detail crd in crds) { _unitOfWork.AddAction(crd, DataActions.Delete); } _unitOfWork.AddAction(studententity, DataActions.Delete); _unitOfWork.Save(); } } else { res = false; throw new FaultException <LCFault>(new LCFault("删除学员失败"), "该学员不存在,无法删除"); } } catch (RepositoryException rex) { string msg = rex.Message; string reason = rex.StackTrace; throw new FaultException <LCFault> (new LCFault(msg), reason); } catch (Exception ex) { string msg = ex.Message; string reason = ex.StackTrace; throw new FaultException <LCFault> (new LCFault(msg), reason); } return(res); }
/// <summary> /// Gets Site Domains by Site Id /// </summary> /// <param name="siteId">Site Id.</param> /// <returns>An enumerable list of SiteDomain objects.</returns> public IEnumerable <SiteDomain> GetBySiteId(int siteId) { return(Repository.Find(t => t.SiteId == siteId)); }
public Result LookupFilter(PersonFilter filter) { return(Return(Repository.Find(x => x.Name.Contains(filter.Name)).Select(ConvertToLookupResponse))); }
/// <summary> /// Gets Site Domains by Site Id And Domain /// </summary> /// <param name="siteId">Site Id.</param> /// <param name="domain">Domain.</param> /// <returns>An enumerable list of SiteDomain objects.</returns> public IEnumerable <SiteDomain> GetBySiteIdAndDomain(int siteId, string domain) { return(Repository.Find(t => t.SiteId == siteId && t.Domain == domain)); }
public virtual T Find(Expression <Func <T, bool> > where) { return(repo.Find(where)); }
public Category FindCategory(int?id) { return(repo_category.Find(x => x.Id == id)); }
protected void LoadEntityByKey(TPrimaryKey primaryKey) { UpdateUnitOfWork(); Entity = Repository.Find(primaryKey); }