Search Results

Search found 119 results on 5 pages for 'bll'.

Page 2/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • Validation in n-tier asp.net mvc applications

    - by sTodorov
    Dear Stack Overflow gurus, I am looking for some practical/theoretical information regarding best practices for validation in asp.net mvc n-tier applications. I am working on a .Net application divided into the following layers: UI - Mvc3 BLL layer - all business rules. Decoupled from data access and UI layers through interfaces DAL layer - Data access with the repository pattern, EF4 and pocos Now, I am looking for a nice, clean and transparent way to specify my validation rules. Here are some thoughts on the matter so far: UI validation should only be responsible for user input and its validity. BLL validation should be handling the validity of the data regarding the application business rules. My main concern is how to bind the BLL and UI validation in the most efficient way. One think I am would like to avoid is having the UI check in a collection of validation and adding manually errors to the ModelState. Furthermore, I do not want to pass the ModelState to the BLL to be populated in there. I will appreciate any thoughts on the matter. P.S. Should this question be marked as a discussion ?

    Read the article

  • Entity Framework in layered architecture

    - by Kamyar
    I am using a layered architecture with the Entity Framework. Here's What I came up with till now (All the projects Except UI are class library): Entities: The POCO Entities. Completely persistence ignorant. No Reference to other projects. Generated by Microsoft's ADO.Net POCO Entity Generator. DAL: The EDMX (Entity Model) file with the context class. (t4 generated). References: Entities BLL: Business Logic Layer. Will implement repository pattern on this layer. References: Entities, DAL. This is where the objectcontext gets populated: var ctx=new DAL.MyDBEntities(); UI: The presentation layer: ASP.NET website. References: Entities, BLL + a connection string entry to entities in the config file (question #2). Now my three questions: Is my layer discintion approach correct? In my UI, I access BLL as follows: var customerRep = new BLL.CustomerRepository(); var Customer = customerRep.GetByID(myCustomerID); The problem is that I have to define the entities connection string in my UI's web.config/app.config otherwise I get a runtime exception. IS defining the entities connectionstring in UI spoils the layers' distinction? Or is it accesptible in a muli layered architecture. Should I take any additional steps to perform chage tracking, lazy loading, etc (by etc I mean the features that Entity Framework covers in a conventional, 1 project, non POCO code generation)? Thanks and apologies for the lengthy question.

    Read the article

  • LINQ to SQL Web Application Best Practices

    - by derek
    In my experience building web applications, I've always used a n-tier approach. A DAL that gets data from the db and populates the objects, and BLL that gets objects from the DAL and performs any business logic required on them, and the website that gets it's display data from the BLL. I've recently started learning LINQ, and most of the examples show the queries occurring right from the Web Application code-behinds(it's possible that I've only seen overly simplified examples). In the n-tier architectures, this was always seen as a big no-no. I'm a bit unsure of how to architect a new Web Application. I've been using the Server Explorer and dbml designer in VS2008 to create the dbml and object relationships. It seems a little unclear to me if the dbml would be considered the DAL layer, if the website should call methods within a BLL, which then would do the LINQ queries, etc. What are some general architecture best practices, or approaches to creating a Web Application solution using LINQ to SQL?

    Read the article

  • How sophisticated should be DAL?

    - by Andrew Florko
    Basically, DAL (Data Access Layer) should provide simple CRUD (Create/Read/Update/Delete) methods but I always have a temptation to create more sophisticated methods in order to minimize database access roundtrips from Business Logic Layer. What do you think about following extensions to CRUD (most of them are OK I suppose): Read: GetById, GetByName, GetPaged, GetByFilter... e.t.c. methods Create: GetOrCreate methods (model entity is returned from DB or created if not found and returned), Create(lots-of-relations) instead of Create and multiple AssignTo methods calls Update: Merge methods (entities list are updated, created and deleted in one call) Delete: Delete(bool children) - optional children delete, Cleanup methods Where do you usually implement Entity Cache capabilities? DAL or BLL? (My choice is BLL, but I have seen DAL implementations also) Where is the boundary when you decide: this operation is too specific so I should implement it in Business Logic Layer as DAL multiple calls? I often found insufficient BLL operations that were implemented in dozen database roundtrips because developer was afraid to create a bit more sophisticated DAL. Thank you in advance!

    Read the article

  • Invalid Cast Exception with Update Panel

    - by user1593175
    On Button Click Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click MsgBox("INSIDE") If SocialAuthUser.IsLoggedIn Then Dim accountId As Integer = BLL.getAccIDFromSocialAuthSession Dim AlbumID As Integer = BLL.createAndReturnNewAlbumId(txtStoryTitle.Text.Trim, "") Dim URL As String = BLL.getAlbumPicUrl(txtStoryTitle.Text.Trim) Dim dt As New DataTable dt.Columns.Add("PictureID") dt.Columns.Add("AccountID") dt.Columns.Add("AlbumID") dt.Columns.Add("URL") dt.Columns.Add("Thumbnail") dt.Columns.Add("Description") dt.Columns.Add("AlbumCover") dt.Columns.Add("Tags") dt.Columns.Add("Votes") dt.Columns.Add("Abused") dt.Columns.Add("isActive") Dim Row As DataRow Dim uniqueFileName As String = "" If Session("ID") Is Nothing Then lblMessage.Text = "You don't seem to have uploaded any pictures." Exit Sub Else **Dim FileCount As Integer = Request.Form(Request.Form.Count - 2)** Dim FileName, TargetName As String Try Dim Path As String = Server.MapPath(BLL.getAlbumPicUrl(txtStoryTitle.Text.Trim)) If Not IO.Directory.Exists(Path) Then IO.Directory.CreateDirectory(Path) End If Dim StartIndex As Integer Dim PicCount As Integer For i As Integer = 0 To Request.Form.Count - 1 If Request.Form(i).ToLower.Contains("jpg") Or Request.Form(i).ToLower.Contains("gif") Or Request.Form(i).ToLower.Contains("png") Then StartIndex = i + 1 Exit For End If Next For i As Integer = StartIndex To Request.Form.Count - 4 Step 3 FileName = Request.Form(i) '## If part here is not kaam ka..but still using it for worst case scenario If IO.File.Exists(Path & FileName) Then TargetName = Path & FileName 'MsgBox(TargetName & "--- 1") Dim j As Integer = 1 While IO.File.Exists(TargetName) TargetName = Path & IO.Path.GetFileNameWithoutExtension(FileName) & "(" & j & ")" & IO.Path.GetExtension(FileName) j += 1 End While Else uniqueFileName = Guid.NewGuid.ToString & "__" & FileName TargetName = Path & uniqueFileName End If IO.File.Move(Server.MapPath("~/TempUploads/" & Session("ID") & "/" & FileName), TargetName) PicCount += 1 Row = dt.NewRow() Row(1) = accountId Row(2) = AlbumID Row(3) = URL & uniqueFileName Row(4) = "" Row(5) = "No Desc" Row(6) = "False" Row(7) = "" Row(8) = "0" Row(9) = "0" Row(10) = "True" dt.Rows.Add(Row) Next If BLL.insertImagesIntoAlbum(dt) Then lblMessage.Text = PicCount & IIf(PicCount = 1, " Picture", " Pictures") & " Saved!" lblMessage.ForeColor = Drawing.Color.Black Dim db As SqlDatabase = Connection.connection Using cmd As DbCommand = db.GetSqlStringCommand("SELECT PictureID,URL FROM AlbumPictures WHERE AlbumID=@AlbumID AND AccountID=@AccountID") db.AddInParameter(cmd, "AlbumID", Data.DbType.Int32, AlbumID) db.AddInParameter(cmd, "AccountID", Data.DbType.Int32, accountId) Using ds As DataSet = db.ExecuteDataSet(cmd) If ds.Tables(0).Rows.Count > 0 Then ListView1.DataSource = ds.Tables(0) ListView1.DataBind() Else lblMessage.Text = "No Such Album Exists." End If End Using End Using 'WebNavigator.GoToResponseRedirect(WebNavigator.URLFor.ReturnUrl("~/Memories/SortImages.aspx?id=" & AlbumID)) Else 'TODO:we'll show some error msg End If Catch ex As Exception MsgBox(ex.Message) lblMessage.Text = "Oo Poop!!" End Try End If Else WebNavigator.GoToResponseRedirect(WebNavigator.URLFor.LoginWithReturnUrl("~/Memories/CreateAlbum.aspx")) Exit Sub End If End Sub The above code works fine.I have added an Update Panel in the page to avoid post back, But when i add the button click as a trigger <Triggers> <asp:AsyncPostBackTrigger ControlID="btnSubmit" /> </Triggers> in the update panel to avoid post back, i get the following error.This happens when i add the button click as a Trigger to the update panel.

    Read the article

  • Linq to LLBLGen query problem

    - by Jeroen Breuer
    Hello, I've got a Stored Procedure and i'm trying to convert it to a Linq to LLBLGen query. The query in Linq to LLBGen works, but when I trace the query which is send to sql server it is far from perfect. This is the Stored Procedure: ALTER PROCEDURE [dbo].[spDIGI_GetAllUmbracoProducts] -- Add the parameters for the stored procedure. @searchText nvarchar(255), @startRowIndex int, @maximumRows int, @sortExpression nvarchar(255) AS BEGIN SET @startRowIndex = @startRowIndex + 1 SET @searchText = '%' + @searchText + '%' -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- This is the query which will fetch all the UmbracoProducts. -- This query also supports paging and sorting. WITH UmbracoOverview As ( SELECT ROW_NUMBER() OVER( ORDER BY CASE WHEN @sortExpression = 'productName' THEN umbracoProduct.productName WHEN @sortExpression = 'productCode' THEN umbracoProduct.productCode END ASC, CASE WHEN @sortExpression = 'productName DESC' THEN umbracoProduct.productName WHEN @sortExpression = 'productCode DESC' THEN umbracoProduct.productCode END DESC ) AS row_num, umbracoProduct.umbracoProductId, umbracoProduct.productName, umbracoProduct.productCode FROM umbracoProduct INNER JOIN product ON umbracoProduct.umbracoProductId = product.umbracoProductId WHERE (umbracoProduct.productName LIKE @searchText OR umbracoProduct.productCode LIKE @searchText OR product.code LIKE @searchText OR product.description LIKE @searchText OR product.descriptionLong LIKE @searchText OR product.unitCode LIKE @searchText) ) SELECT UmbracoOverview.UmbracoProductId, UmbracoOverview.productName, UmbracoOverview.productCode FROM UmbracoOverview WHERE (row_num >= @startRowIndex AND row_num < (@startRowIndex + @maximumRows)) -- This query will count all the UmbracoProducts. -- This query is used for paging inside ASP.NET. SELECT COUNT (umbracoProduct.umbracoProductId) AS CountNumber FROM umbracoProduct INNER JOIN product ON umbracoProduct.umbracoProductId = product.umbracoProductId WHERE (umbracoProduct.productName LIKE @searchText OR umbracoProduct.productCode LIKE @searchText OR product.code LIKE @searchText OR product.description LIKE @searchText OR product.descriptionLong LIKE @searchText OR product.unitCode LIKE @searchText) END This is my Linq to LLBLGen query: using System.Linq.Dynamic; var q = ( from up in MetaData.UmbracoProduct join p in MetaData.Product on up.UmbracoProductId equals p.UmbracoProductId where up.ProductCode.Contains(searchText) || up.ProductName.Contains(searchText) || p.Code.Contains(searchText) || p.Description.Contains(searchText) || p.DescriptionLong.Contains(searchText) || p.UnitCode.Contains(searchText) select new UmbracoProductOverview { UmbracoProductId = up.UmbracoProductId, ProductName = up.ProductName, ProductCode = up.ProductCode } ).OrderBy(sortExpression); //Save the count in HttpContext.Current.Items. This value will only be saved during 1 single HTTP request. HttpContext.Current.Items["AllProductsCount"] = q.Count(); //Returns the results paged. return q.Skip(startRowIndex).Take(maximumRows).ToList<UmbracoProductOverview>(); This is my Initial expression to process: value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource`1[Eurofysica.DB.EntityClasses.UmbracoProductEntity]).Join(value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource`1[Eurofysica.DB.EntityClasses.ProductEntity]), up => up.UmbracoProductId, p => p.UmbracoProductId, (up, p) => new <>f__AnonymousType0`2(up = up, p = p)).Where(<>h__TransparentIdentifier0 => (((((<>h__TransparentIdentifier0.up.ProductCode.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText) || <>h__TransparentIdentifier0.up.ProductName.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText)) || <>h__TransparentIdentifier0.p.Code.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText)) || <>h__TransparentIdentifier0.p.Description.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText)) || <>h__TransparentIdentifier0.p.DescriptionLong.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText)) || <>h__TransparentIdentifier0.p.UnitCode.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText))).Select(<>h__TransparentIdentifier0 => new UmbracoProductOverview() {UmbracoProductId = <>h__TransparentIdentifier0.up.UmbracoProductId, ProductName = <>h__TransparentIdentifier0.up.ProductName, ProductCode = <>h__TransparentIdentifier0.up.ProductCode}).OrderBy( => .ProductName).Count() Now this is how the queries look like that are send to sql server: Select query: Query: SELECT [LPA_L2].[umbracoProductId] AS [UmbracoProductId], [LPA_L2].[productName] AS [ProductName], [LPA_L2].[productCode] AS [ProductCode] FROM ( [eurofysica].[dbo].[umbracoProduct] [LPA_L2] INNER JOIN [eurofysica].[dbo].[product] [LPA_L3] ON [LPA_L2].[umbracoProductId] = [LPA_L3].[umbracoProductId]) WHERE ( ( ( ( ( ( ( ( [LPA_L2].[productCode] LIKE @ProductCode1) OR ( [LPA_L2].[productName] LIKE @ProductName2)) OR ( [LPA_L3].[code] LIKE @Code3)) OR ( [LPA_L3].[description] LIKE @Description4)) OR ( [LPA_L3].[descriptionLong] LIKE @DescriptionLong5)) OR ( [LPA_L3].[unitCode] LIKE @UnitCode6)))) Parameter: @ProductCode1 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @ProductName2 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @Code3 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @Description4 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @DescriptionLong5 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @UnitCode6 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Count query: Query: SELECT TOP 1 COUNT(*) AS [LPAV_] FROM (SELECT [LPA_L2].[umbracoProductId] AS [UmbracoProductId], [LPA_L2].[productName] AS [ProductName], [LPA_L2].[productCode] AS [ProductCode] FROM ( [eurofysica].[dbo].[umbracoProduct] [LPA_L2] INNER JOIN [eurofysica].[dbo].[product] [LPA_L3] ON [LPA_L2].[umbracoProductId] = [LPA_L3].[umbracoProductId]) WHERE ( ( ( ( ( ( ( ( [LPA_L2].[productCode] LIKE @ProductCode1) OR ( [LPA_L2].[productName] LIKE @ProductName2)) OR ( [LPA_L3].[code] LIKE @Code3)) OR ( [LPA_L3].[description] LIKE @Description4)) OR ( [LPA_L3].[descriptionLong] LIKE @DescriptionLong5)) OR ( [LPA_L3].[unitCode] LIKE @UnitCode6))))) [LPA_L1] Parameter: @ProductCode1 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @ProductName2 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @Code3 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @Description4 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @DescriptionLong5 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @UnitCode6 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". As you can see no sorting or paging is done (like in my Stored Procedure). This is probably done inside the code after all the results are fetched. This costs a lot of performance! Does anybody know how I can convert my Stored Procedure to Linq to LLBLGen the proper way?

    Read the article

  • How should I provide access to this custom DAL?

    - by Casey
    I'm writing a custom DAL (VB.NET) for an ordering system project. I'd like to explain how it is coded now, and receive some alternate ideas to make coding against the DAL easier/more readable. The DAL is part of an n-tier (not n-layer) application, where each tier is in it's own assembly/DLL. The DAL consists of several classes that have specific behavior. For instance, there is an Order class that is responsible for retrieving and saving orders. Most of the classes have only two methods, a "Get" and a "Save," with multiple overloads for each. These classes are marked as Friend and are only visible to the DAL (which is in it's own assembly). In most cases, the DAL returns what I will call a "Data Object." This object is a class that contains only data and validation, and is located in a common assembly that both the BLL and DAL can read. To provide public access to the DAL, I currently have a static (module) class that has many shared members. A simplified version looks something like this: Public Class DAL Private Sub New End Sub Public Shared Function GetOrder(OrderID as String) as OrderData Dim OrderGetter as New OrderClass Return OrderGetter.GetOrder(OrderID) End Function End Class Friend Class OrderClass Friend Function GetOrder(OrderID as string) as OrderData End Function End Class The BLL would call for an order like this: DAL.GetOrder("123456") As you can imagine, this gets cumbersome very quickly. I'm mainly interested in structuring access to the DAL so that Intellisense is very intuitive. As it stands now, there are too many methods/functions in the DAL class with similar names. One idea I had is to break down the DAL into nested classes: Public Class DAL Private Sub New End Sub Public Class Orders Private Sub New End Sub Public Shared Function Get(OrderID as string) as OrderData End Function End Class End Class So the BLL would call like this: DAL.Orders.Get("12345") This cleans it up a bit, but it leaves a lot of classes that only have references to other classes, which I don't like for some reason. Without resorting to passing DB specific instructions (like where clauses) from BLL to DAL, what is the best or most common practice for providing a single point of access for the DAL?

    Read the article

  • WCF service is not responding

    - by Costa
    Hi A Flash program is connecting to WCF web service hosted on a server without anti-virus and without firewall and windows server 2003 64 bit environment. The flash return Connection failed message When I sniffer it I found that the Flash program cannot find these requests, http://IP:2805/BLL.svc?xsd=xsd1 http://IP:2805/BLL.svc?xsd=xsd0 The strange thing is that the service work fine with asp.net. also the same service deployed on another server, just work fine!! Is there a work around. Thanks

    Read the article

  • using Autofac in a multi-layered architecture

    - by Kamyar
    I'm fairly new to the DI/IoC concept and would like to use Autofac in a 3-layered ASP.NET Webforms application. UI layer: An ASP.NET webforms website. BLL: Business logic layer which calls the repositories on DAL. DAL: .EDMX file (Entity Model) and ObjectContext with Repository classes which abstract the CRUD operations for each entity. Entities: The POCO Entities. Persistence Ignorant. Generated by Microsoft's ADO.Net POCO Entity Generator. I have asked a more general question here. Basically, I'd like to create an obejctcontext per HttpContext in my DAL. But i don't want to add a reference to DAL in UI or access to HttpContext in DAL directly. I guess this is where IoC tools come to play. The answer to my previous question is a very good example of using Windsor Castle. I'd like to use Autofac as my IoC tool and Don't know how to achieve this. (How to access DAL in application_start to register the component while I don't want to reference it in my UI, what are the proper references to be able to use DAL component in BLL with Autofac, Should I register BLL as a component with Autofac too) Sorry folks for not providing an explicit question and requesting a kind of working example, But I'm very unfamiliar to the whole IoC concept and I don't think I can achieve it to use in my current time-limited project.

    Read the article

  • What's the difference between these LINQ queries ?

    - by SnAzBaZ
    I use LINQ-SQL as my DAL, I then have a project called DB which acts as my BLL. Various applications then access the BLL to read / write data from the SQL Database. I have these methods in my BLL for one particular table: public IEnumerable<SystemSalesTaxList> Get_SystemSalesTaxList() { return from s in db.SystemSalesTaxLists select s; } public SystemSalesTaxList Get_SystemSalesTaxList(string strSalesTaxID) { return Get_SystemSalesTaxList().Where(s => s.SalesTaxID == strSalesTaxID).FirstOrDefault(); } public SystemSalesTaxList Get_SystemSalesTaxListByZipCode(string strZipCode) { return Get_SystemSalesTaxList().Where(s => s.ZipCode == strZipCode).FirstOrDefault(); } All pretty straight forward I thought. Get_SystemSalesTaxListByZipCode is always returning a null value though, even when it has a ZIP Code that exists in that table. If I write the method like this, it returns the row I want: public SystemSalesTaxList Get_SystemSalesTaxListByZipCode(string strZipCode) { var salesTax = from s in db.SystemSalesTaxLists where s.ZipCode == strZipCode select s; return salesTax.FirstOrDefault(); } Why does the other method not return the same, as the query should be identical ? Note that, the overloaded Get_SystemSalesTaxList(string strSalesTaxID) returns a record just fine when I give it a valid SalesTaxID. Is there a more efficient way to write these "helper" type classes ? Thanks!

    Read the article

  • Post complex types to WebApi Client

    - by BumbleBee
    I am new to WebAPI. I have a MVC project and webApi project both reside under the **same solution**. Also, BLL Class library and DAL class library reside under the same solution. Earlier, my MVC project will talk to the BLL now I am trying to create a WebAPi project which stands in between MVC and BLL. Here is what I have come up with so far : I'm using the HTTPClient to post to a WebApi project. My post method on my controller accepts a single parameter (a model). StatsCriteria criteria = new StatsCriteria(); ...... var client = new HttpClient(); var response = client.PostAsJsonAsync("http://localhost:52765/api/reports", criteria).Result; ....... Here's the signature for my controller in Webapi [HttpPost] public CMAReportVM Reports([FromBody] StatsCriteria criteria) { var cmaReport = Service3.GetCMAReport(criteria.Mlsnums); //Create Map to enable mapping business object to View Model Mapper.CreateMap<CMAReport, CMAReportVM>(); // Maps model to VM model class var cmaVM = Mapper.Map<CMAReport, CMAReportVM>(cmaReport); reutn cmaVM; } // and here's my routing: config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } I am getting the following 405 : Method not allowed. As the WebAPI and MVC project both reside under same sloution I am not sure where/how to host my webapi.

    Read the article

  • What is a better, cleaner way of using List<T>

    - by Tim Meers
    I'm looking to implement a few nicer ways to use List in a couple of apps I'm working on. My current implementation looks like this. MyPage.aspx.cs protected void Page_Load(object sender, EventArgs e) { BLL.PostCollection oPost = new BLL.PostCollection(); oPost.OpenRecent(); rptPosts.DataSource = oArt; rptPosts.DataBind(); } BLL Class(s) public class Post { public int PostId { get; set; } public string PostTitle { get; set; } public string PostContent { get; set; } public string PostCreatedDate { get; set; } public void OpenRecentInitFromRow(DataRow row) { this.PostId = (int) row["id"]; this.PostTitle = (string) row["title"]; this.PostContent = (string) row["content"]; this.PostCreatedDate = (DateTime) row["createddate"]; } } public class PostCollection : List<Post> { public void OpenRecent() { DataSet ds = DbProvider.Instance().Post_ListRecent(); foreach (DataRow row in ds.Tables[0].Rows) { Post oPost = new Post(); oPost.OpenRecentInitFromRow(row); Add(oPost); } } } Now while this is working all well and good, I'm just wondering if there is any way to improve it, and just make it cleaner that having to use the two different classes do to something I think can happen in just one class or using an interface.

    Read the article

  • Objectdatasource always passes 0 and startIndex and pageSize in asp.net 2.0

    - by 101873438432680351218
    I have a DevXpress ASPXGridview, and I am using ObjectDataSource for custom paging. This is my objectDataSource code on aspx page. <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetItems" EnablePaging="true" TypeName="BLL.Item" StartRowIndexParameterName="startIndex" MaximumRowsParameterName="pageSize" SelectCountMethod="GetTotalItems" > <SelectParameters> <asp:ControlParameter ControlID="hfNumber" Name="number" Type="string" /> <asp:ControlParameter ControlID="hfDesc" Name="description" Type="string" /> </SelectParameters> </asp:ObjectDataSource> When I put breakpoints in BLL code, I see that it always executes with startIndex and pageSize as 0. It does pass the other two selectparameters correctly. Also the SelectCountMethod (GetTotalItems) never gets executed.

    Read the article

  • Asp.Net Program Architecture

    - by Pino
    I've just taken on a new Asp.Net MVC application and after opening it up I find the following, [Project].Web [Project].Models [Project].BLL [Project].DAL Now, something thats become clear is that there is the data has to do a hell of a lot before it makes it to the View (DatabaseDALRepoBLLConvertToModelControllerView). The DAL is Subsonic, the repositorys in the DAL return the subsonic entities to the BLL which process them does crazy things and converts them into a Model (From the .Models) sometimes with classes that look like this public DataModel GetDataModel(EntityObject Src) { var ReturnData = new DataModel(): ReturnData.ID = Src.ID; ReturnDate.Name = Src.Name; //etc etc } Now, the question is, "Is this complete overkill"? Ok the project is of a decent size and can only get bigger but is it worth carrying on with all this? I dont want to use AutoMapper as it just seems like it makes the complication worse. Can anyone shed any light on this?

    Read the article

  • Reasons not to use MVC architecture for web application

    - by jaywon
    In the past I have primarily built all my web applications using an N-tier architecture, implementing the BLL and DAL layers. Recently, I have started doing some RoR development as well as looking into ASP.NET MVC. I understand the differences between the different architectures(as referenced by some other SO posts), but I can't really think of any reasons why I wouldn't choose an MVC model going forward. Is there any reasons/times in your experience when an MVC architecture would not be suitable, or any reasons why you would choose a BLL/DAL architecture instead?

    Read the article

  • Problems with Optimistic Concurrency through an ObjectDataSource and a GridView

    - by Bloodsplatter
    Hi I'm having a problem in an ASP .NET 2.0 Application. I have a GridView displaying data from an ObjectDataSource (connected to a BLL class which connects to a TabledAdapter (Typed Dataset using optimistic concurrency). The select (displaying the data) works just fine, however, when I update a row the GridView does pass the old values to the ObjectDataSource. <DataObjectMethod(DataObjectMethodType.Update, True)> _ Public Function UpdateOC(ByVal original_id As Integer, ByVal original_fotonummer As Integer, ByVal original_inhoud As String, ByVal original_postdatum As Date?, ByVal fotonummer As Integer, ByVal inhoud As String, ByVal postdatum As Date?) As Boolean Dim tweets As TwitpicOC.TweetsDataTable = adapterOC.GetTweetById(original_id) If tweets.Rows.Count = 0 Then Return False Dim row As TwitpicOC.TweetsRow = tweets(0) SmijtHetErIn(row, original_fotonummer, original_inhoud, original_postdatum) row.AcceptChanges() SmijtHetErIn(row, fotonummer, inhoud, postdatum) Return adapterOC.Update(row) = 1 End Function Public Sub SmijtHetErIn(ByVal row As TwitpicOC.TweetsRow, ByVal original_fotonummer As Integer, ByVal original_inhoud As String, ByVal original_postdatum As Date?) With row .fotonummer = original_fotonummer If String.IsNullOrEmpty(original_inhoud) Then .SetinhoudNull() Else .inhoud = original_inhoud If Not original_postdatum.HasValue Then .SetpostdatumNull() Else .postdatum = original_postdatum.Value End With End Sub And this is the part of the page: <div id='Overzicht' class='post'> <div class='title'> <h2> <a href='javascript:;'>Tweetsoverzicht</a></h2> <p> Overzicht</p> </div> <div class='entry'> <p> <asp:ObjectDataSource ID="odsGebruiker" runat="server" OldValuesParameterFormatString="" SelectMethod="GetAll" TypeName="TakeHomeWeb.BLL.GebruikersBLL"></asp:ObjectDataSource> <asp:ObjectDataSource ID="odsFoto" runat="server" SelectMethod="GetFotosByGebruiker" TypeName="TakeHomeWeb.BLL.FotosBLL"> <SelectParameters> <asp:ControlParameter ControlID="ddlGebruiker" DefaultValue="0" Name="userid" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> <form id="form1" runat="server"> <asp:Label runat="server" AssociatedControlID="ddlGebruiker">Gebruiker:&nbsp;</asp:Label> <asp:DropDownList ID="ddlGebruiker" runat="server" AutoPostBack="True" DataSourceID="odsGebruiker" DataTextField="naam" DataValueField="userid" AppendDataBoundItems="True"> <asp:ListItem Text="Kies een gebruiker" Value="-1" /> </asp:DropDownList> <br /> <asp:Label runat="server" AssociatedControlID="ddlFoto">Foto:&nbsp;</asp:Label> <asp:DropDownList ID="ddlFoto" runat="server" AutoPostBack="True" DataSourceID="odsFoto" DataTextField="url" DataValueField="id" AppendDataBoundItems="True"> <asp:ListItem Value="-1">Kies een foto...</asp:ListItem> </asp:DropDownList> <br /> <div style="float: left"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="odsTweets"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /> <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True" SortExpression="id" /> <asp:BoundField DataField="fotonummer" HeaderText="fotonummer" SortExpression="fotonummer" /> <asp:BoundField DataField="inhoud" HeaderText="inhoud" SortExpression="inhoud" /> <asp:BoundField DataField="postdatum" HeaderText="postdatum" SortExpression="postdatum" /> </Columns> </asp:GridView> <asp:ObjectDataSource ID="odsTweets" runat="server" ConflictDetection="CompareAllValues" DeleteMethod="DeleteOC" OldValuesParameterFormatString="original_{0}" SelectMethod="GetTweetsByFotoId" TypeName="TakeHomeWeb.BLL.TweetsOCBLL" UpdateMethod="UpdateOC"> <DeleteParameters> <asp:Parameter Name="original_id" Type="Int32" /> <asp:Parameter Name="original_fotonummer" Type="Int32" /> <asp:Parameter Name="original_inhoud" Type="String" /> <asp:Parameter Name="original_postdatum" Type="DateTime" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="original_id" Type="Int32" /> <asp:Parameter Name="original_fotonummer" Type="Int32" /> <asp:Parameter Name="original_inhoud" Type="String" /> <asp:Parameter Name="original_postdatum" Type="DateTime" /> <asp:Parameter Name="fotonummer" Type="Int32" /> <asp:Parameter Name="inhoud" Type="String" /> <asp:Parameter Name="postdatum" Type="DateTime" /> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="ddlFoto" Name="foto" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> </div> </form> </p> </div> </div> I've got a feeling there's huge fail involved or something, but I've been staring at it for hours now and I just can't find it.

    Read the article

  • cache and web-farm

    - by user285336
    I need to deploy my web-application on web-farm. Application has the following strings: public static X509Certificate2 GetIdCertificate() { string cacheKey = "Neogov.Insight.IdentityProvider.PrivateKey"; if (HttpContext.Current.Cache[cacheKey] == null) { //Load new. HttpContext.Current.Cache[cacheKey] = new X509Certificate2( System.Web.HttpContext.Current.Server.MapPath("~/") + "\\ID\\" + Neogov.Insight.IdentityProvider.BLL.IdConfig.Instance.IdPKeyFile, Neogov.Insight.IdentityProvider.BLL.IdConfig.Instance.IdPKeyPassword, X509KeyStorageFlags.MachineKeySet); } return (X509Certificate2)HttpContext.Current.Cache[cacheKey]; } will it work or not? If not then how to solve and what is solution? Thanks

    Read the article

  • Implement Exception Handling in ASP.NET C# Project

    - by Shrewd Demon
    hi, I have an application that has many tiers. as in, i have... Presentation Layer (PL) - contains all the html My Codes Layer (CL) - has all my code Entity Layer (EL) - has all the container entities Business Logic Layer (BLL) - has the necessary business logic Data Logic Layer (DLL) - any logic against data Data Access Layer (DAL) - one that accesses data from the database Now i want to provide error handling in my DLL since it is responsible for executing statement like ExecureScalar and all.... And i am confused as to how to go about it...i mean do i catch the error in the DLL and throw it back to the BLL and from there throw it back to my code or what.... can any one please help me how do i implement a clean and easy error handling techinque help you be really appreciated. Thank you.

    Read the article

  • How apply Unit tests in ASP.NET webforms

    - by gre3ns0ul
    Hi guys. I'm developing a website in asp.net webforms with 3 layers; UI, BLL and DAL The website is already developed, but i like have more control about the unit tests of each form Pass specific values at specific inputs for i see, if application survives or not. I already study about NUnit but in webforms in UI layer how can apply these tests? What i wnat is get some way to test UI (validations) without have to access to the BLL as i was an user. I'm trying to add the Unit tests to my app but i not sure how to do it! somebody can help my small-bigger problem? apreciated

    Read the article

  • Creating an n tiered application

    - by aaron
    I am researching architecture for a project that will be started next year. It is mainly a c# web app, but there will be a service layer so that it can talk to our facebook/iphone app. There are a few long running processes, which means that I will be creating a windows process that can handle those. I’m thinking of putting the entire app in the windows service instead of just the long running processes. Asp - wcf - bll Vs Asp - bll I know this will be more scalable. But it is probably overkill as everything will be running on the same box, even the database. This could change down the road if the server can’t handle the traffic like marketing says it will. I don’t have access to production hardware, just my crappy testing box and my local machine. Has anyone decided to go down this route? But mostly, what is the best way to test both methods to get some metrics?

    Read the article

  • Is there a way to access a php class method using javascript through jquery?

    - by Starx
    I have a js script, which is $("#feedbacksubmit").click(function() { if($("#frmfeedback").valid()) { var tname = $("#name").val(); var temail = $("#email").val(); var tphone = $("#phone").val(); var tcontent = $("#content").val(); var tsend = $(this).attr('ts'); $.post ( "bll/index.php", { action: 'mailfeedback', name: tname, email: temail, phone: tphone, content: tcontent, send: tsend }, function(data) { $('.msgbox').html(data); $("#frmfeedback")[0].reset(); }); return false; } }); however, I am trying to see if there is a way to access the class method of bll/index.php directly from the script, instead of posting parameters, to access it

    Read the article

  • DTOs Collections mapping Problem

    - by the_knight5000
    I'm working now on a multi-tier project which has layers as following : DAL BLL GUI Layer and Shared DTOs between BLL and GUI layers. I'm facing a problem in mapping the Objects from DAO To DTO, No problem in the simple objects. The problem is in the Objects who have child collections of another objects. ex: Author Category --Categories --Authors the execution goes in an infinite loop of mapping and it get more complex when I want model Self-join tables ex: Safe Safe --TransferSafe(Collection<Safe>) --TransferSafe(Collection<Safe>) the execution goes in an infinite loop of mapping any suggestions about a good solution or a practical mapping pattern?

    Read the article

  • linq .net with dynamically generated controls

    - by Stuart
    This is a very strange problem and i really dont have a clue whats causing it. What is supposed to happen is that a call to the BLL then DAL returns some data via a linq SPROC call. The retunred IMultipleResults object is processed and all results stored in a hashtable. The hashtable is stored in session and then the UI layer uses these results to dynamically generate some gridviews. Easy you would think. But if i run the code i dont get any gridviews. If i take out the call to the BLL and DAL the gridviews appear but with nothing in them? Why is it the page renders correctly when i take out the call to get the data? Thanks.

    Read the article

  • Dynamic gridview columns event problem

    - by ropstah
    Hi, i have a GridView (selectable) in which I want to generate a dynamic GridView in a new row BELOW the selected row. I can add the row and gridview dynamically in the Gridview1 PreRender event. I need to use this event because: _OnDataBound is not called on every postback (same for _OnRowDataBound) _OnInit is not possible because the 'Inner table' for the Gridview is added after Init _OnLoad is not possible because the 'selected' row is not selected yet. I can add the columns to the dynamic GridView based on my ITemplate class. But now the button events won't fire.... Any suggestions? The dynamic adding of the gridview: Private Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender Dim g As GridView = sender g.DataBind() If g.SelectedRow IsNot Nothing AndAlso g.Controls.Count &gt; 0 Then Dim t As Table = g.Controls(0) Dim r As New GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal) Dim c As New TableCell Dim visibleColumnCount As Integer = 0 For Each d As DataControlField In g.Columns If d.Visible Then visibleColumnCount += 1 End If Next c.ColumnSpan = visibleColumnCount Dim ph As New PlaceHolder ph.Controls.Add(CreateStockGrid(g.SelectedDataKey.Value)) c.Controls.Add(ph) r.Cells.Add(c) t.Rows.AddAt(g.SelectedRow.RowIndex + 2, r) End If End Sub Private Function CreateStockGrid(ByVal PnmAutoKey As String) As GridView Dim col As Interfaces.esColumnMetadata Dim coll As New BLL.ViewStmCollection Dim entity As New BLL.ViewStm Dim query As BLL.ViewStmQuery = coll.Query Me._gridStock.AutoGenerateColumns = False Dim buttonf As New TemplateField() buttonf.ItemTemplate = New QuantityTemplateField(ListItemType.Item, "", "Button") buttonf.HeaderTemplate = New QuantityTemplateField(ListItemType.Header, "", "Button") buttonf.EditItemTemplate = New QuantityTemplateField(ListItemType.EditItem, "", "Button") Me._gridStock.Columns.Add(buttonf) For Each col In coll.es.Meta.Columns Dim headerf As New QuantityTemplateField(ListItemType.Header, col.PropertyName, col.Type.Name) Dim itemf As New QuantityTemplateField(ListItemType.Item, col.PropertyName, col.Type.Name) Dim editf As New QuantityTemplateField(ListItemType.EditItem, col.PropertyName, col.Type.Name) Dim f As New TemplateField() f.HeaderTemplate = headerf f.ItemTemplate = itemf f.EditItemTemplate = editf Me._gridStock.Columns.Add(f) Next query.Where(query.PnmAutoKey.Equal(PnmAutoKey)) coll.LoadAll() Me._gridStock.ID = "gvChild" Me._gridStock.DataSource = coll AddHandler Me._gridStock.RowCommand, AddressOf Me.gv_RowCommand Me._gridStock.DataBind() Return Me._gridStock End Function The ITemplate class: Public Class QuantityTemplateField : Implements ITemplate Private _itemType As ListItemType Private _fieldName As String Private _infoType As String Public Sub New(ByVal ItemType As ListItemType, ByVal FieldName As String, ByVal InfoType As String) Me._itemType = ItemType Me._fieldName = FieldName Me._infoType = InfoType End Sub Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn Select Case Me._itemType Case ListItemType.Header Dim l As New Literal l.Text = "&lt;b&gt;" & Me._fieldName & "</b>" container.Controls.Add(l) Case ListItemType.Item Select Case Me._infoType Case "Button" Dim ib As New Button() Dim eb As New Button() ib.ID = "InsertButton" eb.ID = "EditButton" ib.Text = "Insert" eb.Text = "Edit" ib.CommandName = "Edit" eb.CommandName = "Edit" AddHandler ib.Click, AddressOf Me.InsertButton_OnClick AddHandler eb.Click, AddressOf Me.EditButton_OnClick container.Controls.Add(ib) container.Controls.Add(eb) Case Else Dim l As New Label l.ID = Me._fieldName l.Text = "" AddHandler l.DataBinding, AddressOf Me.OnDataBinding container.Controls.Add(l) End Select Case ListItemType.EditItem Select Case Me._infoType Case "Button" Dim b As New Button b.ID = "UpdateButton" b.Text = "Update" b.CommandName = "Update" b.OnClientClick = "return confirm('Sure?')" container.Controls.Add(b) Case Else Dim t As New TextBox t.ID = Me._fieldName AddHandler t.DataBinding, AddressOf Me.OnDataBinding container.Controls.Add(t) End Select End Select End Sub Private Sub InsertButton_OnClick(ByVal sender As Object, ByVal e As EventArgs) Console.WriteLine("insert click") End Sub Private Sub EditButton_OnClick(ByVal sender As Object, ByVal e As EventArgs) Console.WriteLine("edit click") End Sub Private Sub OnDataBinding(ByVal sender As Object, ByVal e As EventArgs) Dim boundValue As Object = Nothing Dim ctrl As Control = sender Dim dataItemContainer As IDataItemContainer = ctrl.NamingContainer boundValue = DataBinder.Eval(dataItemContainer.DataItem, Me._fieldName) Select Case Me._itemType Case ListItemType.Item Dim fieldLiteral As Label = sender fieldLiteral.Text = boundValue.ToString() Case ListItemType.EditItem Dim fieldTextbox As TextBox = sender fieldTextbox.Text = boundValue.ToString() End Select End Sub End Class

    Read the article

  • How to populate a generic list of objects in C# from SQL database

    - by developr
    I am just learning ASP.NET c# and trying to incorporate best practices into my applications. Everything that I read says to layer my applications into DAL, BLL, UI, etc based on separation of concerns. Instead of passing datatables around, I am thinking about using custom objects so that I am loosely coupled to my data layer and can take advantage of intellisense in VS. I assume these objects would be considered DTOs? First, where do these objects reside in my layers? BLL, DAL, other? Second, when populating from SQL, should I loop through a data reader to populate the list or first fill a data table, then loop through the table to populate the list? I know you should close the database connection as soon as possible, but it seems like even more overhead to populate the data table and then loop through that for the list. Third, everything I see these days says use Linq2SQL. I am planning to learn Linq2SQL, but at this time I am working with a legacy database that doesn't have foreign keys setup and I do not have the ability to fix it atm. Also, I want to learn more about c# before I start getting into ORM solutions like nHibernate. At the same time I don't want to type out all the connection and SQL plumbing for every query. Is it ok to use the Enterprise DAAB for now?

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >