public async Task <IActionResult> Create([Bind("product_type_code,product_group_code,id,product_type_desc,rowversion,x_log,x_note,x_status")] product_type product_type) { _context.Add(product_type); await _context.SaveChangesAsync(); return(Json(new { result = "success" })); }
public static void addTypes(int subcategoryId, String names) { String[] nameList = names.Split(';'); using (DB_entities db = new DB_entities()) { using (TransactionScope scope = new TransactionScope()) { foreach (String name in nameList) { if (name == "") { break; } product_type prodType = new product_type(); prodType.name = name; prodType.subcategory_id = subcategoryId; try { db.product_type.Add(prodType); db.SaveChanges(); } catch (Exception ex) { Log.error("addTypes - Insert.cs", DateTime.Now, ex); } } scope.Complete(); } } }
public async Task <IActionResult> Edit(string id, [Bind("product_type_code,product_group_code,id,product_type_desc,rowversion,x_log,x_note,x_status")] product_type product_type) { if (id != product_type.product_type_code) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product_type); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!product_typeExists(product_type.product_type_code)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(product_type)); }
public void InsertProduct_type(product_type product_type) { if (product_type.EntityState != EntityState.Detached) { this.ObjectContext.ObjectStateManager.ChangeObjectState(product_type, EntityState.Added); } else { this.ObjectContext.product_type.AddObject(product_type); } }
public async Task <IActionResult> Create([Bind("product_type_code,product_group_code,id,product_type_desc,rowversion,x_log,x_note,x_status")] product_type product_type) { if (ModelState.IsValid) { _context.Add(product_type); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(product_type)); }
public void DeleteProduct_type(product_type product_type) { if ((product_type.EntityState != EntityState.Detached)) { this.ObjectContext.ObjectStateManager.ChangeObjectState(product_type, EntityState.Deleted); } else { this.ObjectContext.product_type.Attach(product_type); this.ObjectContext.product_type.DeleteObject(product_type); } }
public async Task <IActionResult> Edit(string id, [Bind("product_type_code,product_group_code,id,product_type_desc,rowversion,x_log,x_note,x_status")] product_type product_type) { if (ModelState.IsValid) { try { _context.Update(product_type); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(Json(new { result = "fail" })); } return(Json(new { result = "success" })); } return(Json(new { result = "fail" })); }
public async Task <ActionResult> Post(product_type type) { if (ModelState.IsValid) { var result = await dbContext.fdc_products_types.AddAsync(type); if (result != null && result.State == EntityState.Added) { await dbContext.SaveChangesAsync(); var response = await dbContext.GetProductType(result.Entity.product_type_id); return(Ok(response)); } } return(BadRequest()); }
public async Task <ActionResult> Put(int id, product_type type) { if (ModelState.IsValid) { type.product_type_id = id; var result = dbContext.fdc_products_types.Update(type); if (result != null && result.State == EntityState.Modified) { await dbContext.SaveChangesAsync(); var response = await dbContext.GetProductType(result.Entity.product_type_id); return(Ok(response)); } } return(BadRequest()); }
/// <summary> /// 保存 /// </summary> /// <param name="theData">保存的数据</param> public ActionResult SaveData(product_type theData) { if (theData.id.IsNullOrEmpty()) { theData.id = Guid.NewGuid().ToSequentialGuid(); theData.create_by = Operator.UserId; theData.create_time = DateTime.Now.ToCstTime(); theData.enable_flag = 1; _product_typeBusiness.AddData(theData); } else { theData.update_by = Operator.UserId; theData.update_time = DateTime.Now.ToCstTime(); _product_typeBusiness.UpdateData(theData); } return(Success()); }
public void UpdateProduct_type(product_type currentfiletype) { this.ObjectContext.product_type.AttachAsModified(currentfiletype, this.ChangeSet.GetOriginal(currentfiletype)); }