public static void DebitUser(string brinqaccountNumber, double Amount) { Transaction transaction = new Transaction(); var db = new Kaedc(); var user = db.Kaedcuser.Where(k => k.BrinqaccountNumber == brinqaccountNumber).FirstOrDefault(); //update user's balance var amount = Convert.ToInt64(Amount); user.MainBalance = user.MainBalance - amount; //update DB transaction.Id = GenerateId(); transaction.ServiceId = 3; transaction.Amount = Amount; transaction.PayersName = user.UserName; transaction.PaymentMethodId = 1; transaction.transactionsStatus = "completed"; transaction.Datetime = DateTime.Now; transaction.KaedcUserNavigation = user; transaction.Service = db.Service.Where(s => s.Id == 4).FirstOrDefault(); db.Add(transaction); db.SaveChanges(); }
public IActionResult Update([FromRoute] string ID) { // Get the model Kaedcuser model = db.Kaedcuser.Where(m => m.Id == ID).FirstOrDefault(); // Update properties //model.timestamp = DateTime.UtcNow; //model.applied_by = System.Web.HttpContext.Current.User.Identity.Name; //model.status = "Done"; if (model.IsActive == 0) { model.IsActive = 1; } else { model.IsActive = 0; } // Save and redirect db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("customerList")); }