C# - Merging These Two Very Similar Methods

Aug 9, 2010

I have these two methods on a service:

public Offer GetOffer(int id, string languageCode = Website.LanguageSettings.DefaultLanguageCode)
{
Entities.Offer offerEntity = _db.Offers.FirstOrDefault(offer => offer.Id == id);
if (languageCode.ToLower(CultureInfo.InvariantCulture) != Website.LanguageSettings.DefaultLanguageCode)
{
using (IDocumentSession session = store.OpenSession())
{
Translation.Offer translatedOffer = session.LuceneQuery<Translation.Offer>(Website.RavenDbSettings.Indexes.Offers)
.Where(string.Format("ObjectId:{0} AND LanguageCode:{1}", id, languageCode))
.OrderByDescending(offer => offer.Id)
.FirstOrDefault();
var offerPOCO = Mapper.DynamicMap<Translation.Offer, Offer>(translatedOffer);
offerPOCO.Id = offerEntity.Id;
return offerPOCO;
}
}
return Mapper.Map<Entities.Offer, Offer>(offerEntity);........................................

View 4 Replies


Similar Messages:

Using Extension Methods In Static Methods On Extended Classes?

Aug 16, 2010

I have an extension method as follows:

public static class PageExtensions
{
public static int GetUserId(this Page targetPage)
{
var user = Membership.GetUser(targetPage.User.Identity.Name);
return (int)user.ProviderUserKey;
}
}

Now in a page I need to use this method in a static WebMethod, so I have added another 'extension method' to PageExtensions:

public static int GetUserId()
{
return (int)Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey;
}

and I call it as follows in my WebMethod: PageExtensions.GetUserId()

View 1 Replies

Web Forms :: How To Change This Methods In To Use Dictionary Or Extension Methods

Jul 23, 2010

public class CacheHelper { /// <summary> /// Removes object with the specified key. /// </summary> /// <param name="key">The key.</param> [code]....

I have this methods for caching..I need to change this methods to use in aDictionary<string,object>

How do I need to change this code Because I am new to asp.net I am still learning..

View 12 Replies

Security :: Not Extending MembershipProvider Class And Putting All This Methods In Some Unique Class And Call Its Methods Then?

Sep 16, 2010

I am beginner in web applications development. I started one little project and host it on source forge "https://homoco.svn.sourceforge.net/svnroot/homoco". And I started implementing authentication in this application to learn how it works. From my experience people never use out of the box things so I want to implement this stuff alone (like in real world projects). So some questions:

1) Is there any reason to use membership out of the box? To use database table schema, stored procedures etc. that tool generate for developer. I think that this lower control over code and I decided to implement it my self. I don't know if I am right.

2) Is my approach in this demo project good or bad (if someone have time I like to do just a little code review)? I created database based on business rules. Not using database schema that membership provider require. Extend "MembershipProvider" class to satisfy my needs. Implement queries to database myself.

3) Now, this question is a little wired but I have to ask it. If we make custom Membership Provider and do sql queries alone, implement all MembershipProvider class methods ourselves, and in application use Membership.blabla() why is this approach different from not extending MembershipProvider class and putting all this methods in some unique class and call its methods then? I hope that someone understand what I ask here.

I am sorry for three questions, but I really trying to find the best way to implement this feature in my demo project like it is a real world application.

View 3 Replies

Merging Data In Datagridview

Mar 23, 2011

I am building a web page that will be presenting users two dataset results from two stored procedures in sql but the data is not similar. Is it possible to present both datasets to users in one datagridview? I am unable to do a union of the data in SQL due to the fact that the results aren't similar and wanted to see if I could work around this issue with .net.

View 3 Replies

Merging Two Datasets Into One Grid?

Mar 20, 2010

I have two datasets called ds and ds1 that I want to merge into a grid. I get data from the first dataset to display in the grid but the second dataset where I want to display a count I don't get any data from it. I am trying a ds.Merge(ds1). here is the code i have for the sub. What am I doing incorrectly?

Code:

[code]....

View 9 Replies

Merging Changes To Published Site

Jan 14, 2011

I created an ASP.NET site in Visual Web devloper 2010 & then published it to our webserver. Due to the nature of the site, there are several users updating the content on the site (e.g. news pages). Is there a simple way to merge these changes back into my project? Can I just copy the published site back over my project folder which should overwrite the aspx pages but leave the code behinds untouched?

View 4 Replies

Merging JavaScript Files Together On The Fly In .NET

Feb 23, 2010

Is it possible to merge several JavaScript files being used on a site into one? I'm looking to do this to minimize server loads by forcing only one download. This way I can keep my JavaScript organized into separate files and still have efficiency.

View 2 Replies

MVC :: Razor: Merging Javascript With C#?

Feb 1, 2011

I want to access to the ViewBag from javascript, so I can access to this variable in the future from javascript.Im trying to do this:

var array = new Array();
@for (int i = 0; i < 5; i++)
{
array[i] = @ViewBag.FriendsId[i]);
}

View 5 Replies

SQL Server :: Merging Three Tables Together In One Table?

Jan 7, 2011

I have three tables. I need to merge these three tables into one table. There is an ID column in all these three tables. The ID's can be same in all three tables or they can be different. If the IDs are same then I need to merge based on those ID's so if the ID 1 exists in Table A, table B and Table C then one row will be created in the resulting master tables, but if the Id's are different then one individual row will be created in each table.

Also, some of the columns are same in all three tables, but some are different, but if the ID is same then I just want to append that column in the existing table.

View 4 Replies

Accessing Merging IIS Extended Log Files?

Oct 18, 2010

I need to access, merge and parse my log files using my asp.net application programmatically. I use shared hosting and as I can see log files are out of the root directory of my website? Is there anyway to access those files from my application?

View 1 Replies

Merging Rows From Sql Query Result?

Sep 15, 2010

What would it be the simplest way to merge a result like this from a sql query to be displayed in an asp.net gridview?

NULL Tarde Fer W. Lunes
Mañana NULL Fer W. Lunes

I need the result to look like this

Mañana Tarde Fer W. Lunes

View 2 Replies

When A Few Users Try To Log Into Site - Their Sessions Are Merging?

Feb 16, 2011

i lunched an asp.net web-site. the main idea in the site is that:the site shows the same page, but on each next button the user clicks, the pictures in the site change randomly. im working with postback and sessions.

i noticed that when a few users try to log into my site - their sessions are merging. meaning, the first picture presented is diffrent but the second picture is the same for all the users, and so on... (moreover, pictures that appears in the begining appearing again even thow i don't allw it in my code)when i tried to debug the site locally, the random function works perfectly and there were no such problems. it haapens only when 2 users and more log into my site.

View 1 Replies

JQuery :: Merging 2 Functions Using Jcrop?

Oct 15, 2010

I'm very new to jQuery, and have little experience using JavaScript,I've found what to me looks like a fantastic crop tool using jQuery ( http://deepliquid.com/content/Jcrop.html ).What I need is to merge example 2 and 3 together, as I'd like both the preview panel AND I need the coordinates. The two bits of JS are:

<script language="Javascript">

// Remember to invoke within jQuery(window).load(...)

// If you don't, Jcrop may not initialize properly[code]....

View 2 Replies

C# - Merging Two Datasets Which Have 1 Column In Common?

Nov 18, 2010

I have a dataset dsvalue that has columns Id and views. An other dataset has quite a number of columns including Id. So for each id in dataset ds, i should add a new column "Views" and merge it with views from dsvalue.

View 1 Replies

DataSource Controls :: Merging SQL Databases?

Jan 3, 2010

Before I can upload my web site I need to merge my 6 small databases into one otherwise I am going to pay unreasonable hosting fees.Is there any easy way to do this?

View 4 Replies

Security :: Merging Membership Tables With Database?

Mar 7, 2010

I am using aspnet_regsql.exe to add membership tables to my database.

when I click the exe file it just opens up an XML file in visual web developer and does not start the wizard to merge the databases.

the run command where file is located is below

C:WINDOWSMicrosoft.NETFrameworkv2.0.50727

I just get the file below opening instead

[Code]...

View 1 Replies

DataSource Controls :: Merging Aspnetdb.mdf With Other Mdf File

Jan 18, 2010

i would like to move all membership tables from aspnetdb.mdf to another mdf file. I don't have connection string in web.config that points to aspnetdb.mdf. I found links like [URL], but aspnet_regsql.exe allows to move all security data to sql server, not mdf file.

View 5 Replies

Merging / Filling Pdf Form File With Xml Data?

Apr 9, 2010

Let's say I have a pdf form file available at website which is filled by the users and submitted to the server. On the server side (Asp.Net) I would like to merge the data that I receive in xml format with the empty pdf form that was filled and save it.

As I have found there are several possible ways of doing it:

Using pdf form created by adobe acrobat and filling it with itextsharp. Using pdf form created by adobe acrobat and filling it with FDF Toolkit .net (which seems to be using itextsharp internally) Usd pdfkt to fill the form. Use pdf form file created with adobe livecycle and merge the data by using Form Data Integration Service

View 2 Replies

C# - Merging Merger Header Columns In Gridview?

Nov 16, 2010

How can I create below type of gridview with merge merged header columns? If anybody have example share with me.

View 1 Replies

DataSource Controls :: Merging Binary Data?

Jul 27, 2010

I have several cases in my database and for each case there is binary data. I am reading binary data for each case in a byte attray and saving it as a pdf file.I can succesfully open this pdf file.

protected string SavePdfFromDB(string caseNum)
{
string PDFFileName = string.Empty;
SqlDataReader dr = csiDelegate.DataReaderProcedure("GetReportFilenameForFileSystemNewestFile", [code]....

Can I read this binary data for multiple cases in the same byte aray and and save it as a pdf? Will this create a valid readable pdf?

View 3 Replies

Forms Data Controls :: Merging All Tables In A Dataset?

Mar 27, 2010

I have a members section of a website where when they first register to become a member, they pick their top 5 sports personalities/stars. Then when they log in to the members area, I want to display members news which should show:

- at the top all new stories that have been their sportstar has been referenced to

- then all other news

(In the CMS, admins can edit a news story and they have 5 dropdowns of all the sportstars so they can for example have for a news story: Sportstar1=Tiger Woods, Sportstar2=David Beckham etc) So as a member, if I have selected David Beckham as one of my top 5s, then all news tagged with him via the CMS are displayed.

There may be a better way to approach it, but basically I am creating one DataSet, then firing off 5 SQL queries, each SQL query is like this:

[Code]....

Then in my Page Load I do this:

[Code]....

The problem is that my repeater is inl showing news for myStar1 i.e. it is nly showing the first table which will be called "News1".

So is there any easier way of doing this? Am I overcomplicating things?

View 2 Replies

C# - Create A Process Of Merging Letters And / Or Envelope Templates From Web App

Aug 24, 2010

I need to create a process of merging letters and/or envelope templates from a web app. We are using VS2010, C# (.net 4.0), asp.net, and Office 2007. The user selects a bunch of accounts from a list, and I need to collect the info for those accounts for merge. One catch is that if I look up an account and one of the two account holders has passed away, I need to change the greeting based on that info. For example, in most cases the letter would say something like Mr. and Mrs. Bob Smith. But if bob is dead, then it would just say Mrs. Mary Smith.

I also need it to open on the client side in word ready to print. So if the letter is 1 page, and the user selects 100 accounts, the word doc should have the letter merged with the 100 accounts just waiting for print. What is the best way to do this?

View 2 Replies

Forms Data Controls :: Merging Rss Feeds And Display In One?

Dec 27, 2010

I have a couple of rss feeds i want to merge into one and show on my site. I know how to display one feed but haven't found a way of displaying several feeds.

[Code]....

View 7 Replies

SQL Reporting :: Merging Cells With Visual Studio 2008

May 24, 2010

i having trouble merging cells in reporting service with visual studio 2008 i want to merge a cell that has data of a group and detail i can't is there any way Here is an image of what i'm trying to do

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved