public IHttpActionResult ChangeUserByAddShopCartStateOrMoney(ChangeBadEvaluateModel model) { int result = 0; if (model.State == 1) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.AddShopCart.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.State = 2; //DbEntityEntry entry = entities.Entry(query); //entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } } } if (model.State == 2) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.AddShopCart.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.State = 4; //DbEntityEntry entry = entities.Entry(query); //entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } } } if (model.State == 3) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.AddShopCart.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.Price = model.Price; //DbEntityEntry entry = entities.Entry(query); //entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } } } if (result > 0) { return(Ok(Respone.Success("修改成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult ChangeUserByEvaluateStateOrMoney(ChangeBadEvaluateModel model) { int result = 0; if (model.State == 1) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.Evaluate.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.State = 2; result = entities.SaveChanges(); } } } if (model.State == 2) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.Evaluate.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.State = 5; result = entities.SaveChanges(); } } } if (model.State == 3) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.Evaluate.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.Price = model.Price; result = entities.SaveChanges(); } } } if (result > 0) { return(Ok(Respone.Success("修改成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }
public IHttpActionResult ChangeUserByBugQueryStateOrMoney(ChangeBadEvaluateModel model) { int result = 0; if (model.State == 1) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.BugQuery.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.State = 2; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); var customerFinance = entities.AroundUserFinance.Where(t => t.UserId == query.UserId).FirstOrDefault(); customerFinance.AccountBalance = customerFinance.AccountBalance - query.Price; customerFinance.AccumulatedExpenditure = customerFinance.AccumulatedExpenditure + query.Price; DbEntityEntry entryc = entities.Entry(customerFinance); entryc.State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); //记录流水 TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); AroundUserFinanceLog log = new AroundUserFinanceLog { BusinessNumber = Convert.ToInt64(ts.TotalMilliseconds).ToString(), UserId = query.UserId, PaymentState = 9, TransactionType = 1, TransactionTime = DateTime.Now, TransactionAmount = query.Price, Remarks = "任务:" + query.Id + " 死因查询支出" }; entities.AroundUserFinanceLog.Add(log); result = entities.SaveChanges(); } } } else if (model.State == 2) { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.BugQuery.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.State = 5; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } } } else { for (int i = 0; i < model.Id.Length; i++) { int c = model.Id[i]; var query = entities.BugQuery.Where(e => e.Id == c).FirstOrDefault(); if (query != null) { query.Price = model.Price; DbEntityEntry entry = entities.Entry(query); entry.State = System.Data.Entity.EntityState.Modified; result = entities.SaveChanges(); } } } if (result > 0) { return(Ok(Respone.Success("修改成功"))); } else { return(Ok(Respone.No("发生了点问题,请稍后再试"))); } }