public ActionResult Save(int ProjectId, string jsonArr) { List <SupplierEvaAnswer> SupplierEvaAnswers = JsonConvert.DeserializeObject <List <SupplierEvaAnswer> >(jsonArr); foreach (SupplierEvaAnswer answer in SupplierEvaAnswers) { if (!answer.SupplierScore.HasValue) { continue; } if (answer.Id > 0) { answer.ModifyDateTime = DateTime.Now; answer.ModifyUserId = UserInfo.UserId; db.Entry <SupplierEvaAnswer>(answer).State = System.Data.Entity.EntityState.Modified; } else { answer.ProjectId = ProjectId; answer.InDateTime = DateTime.Now; answer.InUserId = UserInfo.UserId; db.SupplierEvaAnswer.Add(answer); } } db.SaveChanges(); return(Json("")); }
public IHttpActionResult PutPurchaseOrderTable(int id, PurchaseOrderTable purchaseOrderTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != purchaseOrderTable.PurchaseOrderID) { return(BadRequest()); } db.Entry(purchaseOrderTable).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PurchaseOrderTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult SavePerson(ProjectPerson person) { if (person.SeqNO == 0) {//新增 int maxOne = db.ProjectPerson.Where(x => x.ProjectId == person.ProjectId).OrderByDescending(x => x.SeqNO).Select(x => x.SeqNO).FirstOrDefault(); person.SeqNO = maxOne + 1; person.InDateTime = DateTime.Now; person.InUserId = UserInfo.InUserId; db.ProjectPerson.Add(person); } else { db.Entry(person).State = EntityState.Modified; } db.SaveChanges(); return(Json(new { Status = true, Data = person })); }