public void paytmJob() { var data = entities.Transactions.Where(x => x.WithdrawType == "Paytm" && x.paymentStatus == "Pending").ToList(); string hostName = Dns.GetHostName(); // Retrive the Name of HOST string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); // Get the IP GeneralFunctions general = new GeneralFunctions(); var earn = general.getEarningHeads(); foreach (var item in data) { int amount = (int)item.amount - earn.WithdrawCharges; if (amount > 0) { var pay = PaytmResponse(item.mobilenumber, "Withdrawal Amount in Paytm", amount.ToString(), myIP); var paytmResult = JsonConvert.DeserializeObject <paytmResponse.Root>(pay); if (paytmResult.statusCode == "SUCCESS" && paytmResult.status == "SUCCESS") { item.paymentStatus = "withdrawal"; } item.PaytmOrderId = paytmResult.orderId; item.PaytmResponse = pay; ////db.Entry(old).CurrentValues.SetValues(model); ////return db.SaveChanges() > 0; /// //entities.SaveChanges(); entities.Entry(item).CurrentValues.SetValues(item); entities.SaveChanges(); } } }
public void Update(QuizItemQuestion model) { using (var context = new QuizAppEntities()) { var existingEntity = context.QuizItemQuestions.FirstOrDefault(o => o.Id == model.Id); if (existingEntity == null) { return; } context.Entry(existingEntity).CurrentValues.SetValues(model); context.SaveChanges(); } }
public bool UpdatePassword(string UserId, string Password) { using (QuizAppEntities model = new QuizAppEntities()) { var userInfo = model.Users.Where(x => x.UserID == UserId).FirstOrDefault(); if (userInfo != null) { userInfo.Password = Password; userInfo.LastUpdateDate = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00); model.Entry(userInfo).State = EntityState.Modified; return(model.SaveChanges() > 0); } else { return(false); } } }