Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4066252
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:06:38+00:00 2026-05-20T16:06:38+00:00

My controller: [HttpPost] public ActionResult Deposit(DepositTicket dt) { using (var db = new MatchGamingEntities())

  • 0

My controller:

[HttpPost]
    public ActionResult Deposit(DepositTicket dt)
    {
        using (var db = new MatchGamingEntities())
        {
            MembershipUser currentUser = Membership.GetUser();
            Guid UserId = (Guid)currentUser.ProviderUserKey;
            var MyAccount = from a in db.Accounts
                            where a.UserId == UserId
                            select new Account{ 
                                AccountId = a.AccountId,                                 
                                Balance = a.Balance
                                };

            BankTransaction transaction = new BankTransaction();
            transaction.Amount = dt.Amount;
            transaction.AccountId = MyAccount.SingleOrDefault().AccountId;
            transaction.Created = DateTime.Today;
            transaction.TransactionType = "Credit";
            Debug.Write("Amount: " + transaction.Amount + " AccountId " + transaction.AccountId);
            db.BankTransactions.AddObject(transaction);
            MyAccount.SingleOrDefault().Balance += transaction.Amount;
            //Update Query

            db.SaveChanges();
            return View();
        }

Where the comment “Update Query” is, is where I want to add an update query to updated the Account table with an Account object. I want to update the exisiting record, can this be done using the predefined functions for db.Accounts or would I have to write a linq query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:06:39+00:00Added an answer on May 20, 2026 at 4:06 pm

    It seems like you are going to an awful lot of trouble to get a custom account object to then just want to update the original account record. I would suggest just working with the original account object and make the necessary updates, then when SaveChanges is called it will update your account record.

    Here are my suggested changes

    public ActionResult Deposit(DepositTicket dt)
    {
        using (var db = new MatchGamingEntities())
        {
            MembershipUser currentUser = Membership.GetUser();
            Guid UserId = (Guid)currentUser.ProviderUserKey;
            var MyAccount = db.Accounts.SingleOrDefault(a => a.UserId == UserId);
    
            BankTransaction transaction = new BankTransaction();
            transaction.Amount = dt.Amount;
            transaction.AccountId = MyAccount.AccountId;
            transaction.Created = DateTime.Today;
            transaction.TransactionType = "Credit";
            Debug.Write(String.Format("Amount: {0} AccountId: {1}", transaction.Amount, transaction.AccountId);
            db.BankTransactions.AddObject(transaction);
            MyAccount.Balance += transaction.Amount;
    
            db.SaveChanges();
            return View();
        }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MVC 3 and I have the following controller: [HttpPost] public ActionResult
here is my root controller : [HttpPost] public ActionResult Index() { } but it
Here is my controller: [HttpPost] public ActionResult Index(HttpPostedFileBase excelFile) { /*Somewhere here, I have
Here is what I have: Controller [HttpPost] public ActionResult GetNumbers(int id) { List<int> privIDs
In my MVC 3 application I have a very basic controller [HttpPost] public ActionResult
this is my controller: public ActionResult Create() { Number newNumber = new Number(); return
this is my controller: public ActionResult Create() { Number newNumber = new Number(); return
This is the code that I have in my controller: [HttpPost] public ActionResult UpdateArticle(Article
My controller, in a nutshell is this: chart1.SeriesCollection.Add(SC); using (MemoryStream ms = chart1.GetChartStream()) {
I have a controller with an action method as follows: public class InventoryController :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.