public async Task <IHttpActionResult> Put([FromBody] putBodyParam param) { ResultInfo rAjaxResult = new ResultInfo(); try { db0 = getDB0(); //item = await db0.ProductKind.FindAsync(param.id); var md = param.md; md.i_UpdateDateTime = DateTime.Now; md.i_UpdateDeptID = departmentId; md.i_UpdateUserID = UserId; db0.Entry(md).State = EntityState.Modified; await db0.SaveChangesAsync(); rAjaxResult.result = true; } catch (Exception ex) { rAjaxResult.result = false; rAjaxResult.message = ex.ToString(); } finally { db0.Dispose(); } return(Ok(rAjaxResult)); }
public async Task <IHttpActionResult> Put([FromBody] putBodyParam param) { ResultInfo rAjaxResult = new ResultInfo(); try { db0 = getDB0(); item = await db0.Edit.FindAsync(param.id); var md = param.md; item.edit_name = md.edit_name; item.edit_content = md.edit_content; item.sort = md.sort; await db0.SaveChangesAsync(); rAjaxResult.result = true; } catch (Exception ex) { rAjaxResult.result = false; rAjaxResult.message = ex.ToString(); } finally { db0.Dispose(); } return(Ok(rAjaxResult)); }
public async Task <IHttpActionResult> Put([FromBody] putBodyParam param) { ResultInfo rAjaxResult = new ResultInfo(); try { db0 = getDB0(); item = await db0.Customer.FindAsync(param.id); var md = param.md; item.i_UpdateDateTime = DateTime.Now; item.i_UpdateDeptID = departmentId; item.i_UpdateUserID = UserId; item.c_name = md.c_name; item.gender = md.gender; item.tel = md.tel; item.mobile = md.mobile; item.zip = md.zip; item.address = md.address; item.birthday = md.birthday; //db0.Entry(md).State = EntityState.Modified; await db0.SaveChangesAsync(); rAjaxResult.result = true; } catch (Exception ex) { rAjaxResult.result = false; rAjaxResult.message = ex.ToString(); } finally { db0.Dispose(); } return(Ok(rAjaxResult)); }
public async Task <IHttpActionResult> Put([FromBody] putBodyParam param) { ResultInfo rAjaxResult = new ResultInfo(); try { db0 = getDB0(); item = await db0.Editor_L1.FindAsync(param.id); var md = param.md; #region detail update var details = item.Editor_L2; foreach (var detail in details) { var md_detail = md.Deatil.FirstOrDefault(x => x.editor_l2_id == detail.editor_l2_id); if (detail.sort != md_detail.sort || detail.l2_name != md_detail.l2_name || detail.l2_content != md_detail.l2_content) { detail.i_UpdateUserID = UserId; detail.i_UpdateDateTime = DateTime.Now; detail.i_UpdateDeptID = departmentId; } detail.sort = md_detail.sort; detail.l2_name = md_detail.l2_name; detail.l2_content = md_detail.l2_content != null?RemoveScriptTag(md_detail.l2_content) : null; } #endregion #region add var add_detail = md.Deatil.Where(x => x.edit_type == IEditType.Insert); foreach (var detail in add_detail) { var add_item = new Editor_L2() { editor_l1_id = md.editor_l1_id, editor_l2_id = GetNewId(CodeTable.Editor_L2), l2_name = detail.l2_name, l2_content = detail.l2_content != null?RemoveScriptTag(detail.l2_content) : null, sort = detail.sort, i_Hide = false, i_InsertUserID = UserId, i_InsertDateTime = DateTime.Now, i_InsertDeptID = departmentId, i_UpdateUserID = UserId, i_UpdateDateTime = DateTime.Now, i_UpdateDeptID = departmentId, i_Lang = "zh-TW" }; details.Add(add_item); } #endregion item.name = md.name; item.sort = md.sort; item.hide_add = md.hide_add; item.hide_del = md.hide_del; item.hide_sort = md.hide_sort; await db0.SaveChangesAsync(); rAjaxResult.result = true; } catch (Exception ex) { rAjaxResult.result = false; rAjaxResult.message = ex.ToString(); } finally { db0.Dispose(); } return(Ok(rAjaxResult)); }
public async Task <IHttpActionResult> Put([FromBody] putBodyParam param) { ResultInfo rAjaxResult = new ResultInfo(); rAjaxResult.hasData = true; try { db0 = getDB0(); item = await db0.Purchase.FindAsync(param.id); var md = param.md; #region 更新狀態 //出貨狀態 if (md.ship_state == (int)IShipState.shipped & item.ship_state != (int)IShipState.shipped) { item.ship_state = (int)IShipState.shipped; item.ship_date = DateTime.Now; } else if (md.ship_state == (int)IShipState.unshipped) { item.ship_state = (int)IShipState.unshipped; item.ship_date = null; } //取消 if (md.cancel_order == true) { item.pay_state = (int)IPayState.cancel_order; item.ship_state = (int)IShipState.cancel_order; item.cancel_reason = md.cancel_reason; } #endregion if (md.is_mail) { ShipEmail emd = new ShipEmail() { no = md.purchase_no, day = item.ship_date, name = md.receive_name, mail = md.receive_email }; ResultInfo sendmail = (new EmailController()).sendShipMail(emd); if (!sendmail.result) { rAjaxResult.hasData = sendmail.result;//暫時放hasdata rAjaxResult.message = sendmail.message; } } //db0.Entry(md).State = EntityState.Modified; await db0.SaveChangesAsync(); rAjaxResult.result = true; } catch (Exception ex) { rAjaxResult.result = false; rAjaxResult.message = ex.ToString(); } finally { db0.Dispose(); } return(Ok(rAjaxResult)); }