简体   繁体   中英

Retrieve method information c# mvc4

So I just created a method that inherits with Facebook and retrieves some information from a user. What I want now is to send that information to another method so I can put that information to my database.

I'm going to show you the last "stick" in my first method (where I retrieve facebook info) and show you the first "stick" of the second method. Please if you have any ideas on how to do this, reply!

So this is when I add all facebook info from my AuthorizeFacebook method.

  GetFacebook.Add(new FacebookInformation
                {
                        Birthday = fbBirthday,
                        FbEmail = fbEmail,
                        FbId = fbId,
                        FbImage = fbPicture,
                        FbLastName = fbLastName,
                        Location = fbLocation,
                       FbName = fbName,
                });
                model.FacebookInformation = GetFacebook;

and after this I got a new method only:

public void CreateUser()
{
// get the "GetFacebook" class in here?
}

your question is very unclear. Are you looking for something like this:

public void CreateUser(IEnumerable<FacebookInformation> facebookInfo)
{
    // write everything from facebookInfo into database
}

You can do something like this:

return RedirectToAction("CreateUser", "SomeController", model);

where model is this model.FacebookInformation = GetFacebook; where you put the information. You can even use your current model's property to pass on:

model.FacebookInformation = GetFacebook;
return RedirectToAction("CreateUser", "SomeController", model.FacebookInformation);

and use 
public void CreateUser(List<FacebookInformation> info)
{
// get the "GetFacebook" class in here?
}

if you don't need the whole model you can create smaller model only for that property "FacebookInformation" and pass only this model like this:

 publuc class FacebookInformationModel
 {
     public sometype Birthday { get; set; }
     public sometype FbEmail { get; set; }
     public sometype FbId { get; set; }
     public sometype FbImage { get; set; }
     public sometype FbLastName { get; set; }
     public sometype Location { get; set; }
     public sometype FbName { get; set; }
 }

or if GetFacebook returns collection

public class FacebookInformationModel
{
    public List<FacebookInformation> info { get; set; }
}

and then pass it at the end of the 1st method like this again :

FacebookInformationModel info = GetFacebook;
return RedirectToAction("CreateUser", "SomeController", info);

the get method looks like this:

public void CreateUser(FacebookInformationModel model)
{
// get the "GetFacebook" class in here?
}

I'm just guessing here as you have not provided what GetFacebook is as structure( I guess some sort of collection as you use .Add) and also what model.FacebookInformation property holds as values , but i assume it is something like List.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM