public void DeleteWithOutSaveChange(int id_inspection) { var query = this.GetForInspection(id_inspection); foreach (var item in query) { #region 取資料 Inspection_Image inspectionimage = this.Get(item.ID_Inspection_Image); #endregion #region 邏輯驗證 if (inspectionimage == null)//沒有資料 { throw new Exception("MessageNoData".ToLocalized()); } #endregion #region 變為Models需要之型別及邏輯資料 #endregion #region Models資料庫 this._repository.Delete(inspectionimage); #endregion } }
public ActionResult Edit(Inspection model, IEnumerable <HttpPostedFileBase> file) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 if (file != null && file.Count() > 0) { foreach (var item in file) { if (item != null) { int contentLength = item.ContentLength; byte[] byteImage = new byte[contentLength]; item.InputStream.Read(byteImage, 0, contentLength); Inspection_Image image = new Inspection_Image() { ID_Inspection = model.ID_Inspection, BI_Inspection_Image = byteImage, FG_Type = 0, }; model.Inspection_Image.Add(image); } } } model.CX_Modify = UserModel.GetUserData().StaffID; model.DT_Modfiy = DateTime.Now; #endregion #region Service資料庫 this._inspetionService.Update(model); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public ActionResult DeleteConfirmed(int?id) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!id.HasValue) { return(View("Error")); } #endregion #region 前端資料變後端用資料ViewModel時用 #endregion #region Service資料庫 Inspection_Image inspection_image = new Inspection_Image() { ID_Inspection_Image = (int)id }; this._inspectionimageService.Delete(inspection_image); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }
public void Delete(Inspection_Image model) { #region 取資料 Inspection_Image query = this.Get(model.ID_Inspection_Image); #endregion #region 邏輯驗證 if (query == null)//沒有資料 { throw new Exception("MessageNoData".ToLocalized()); } #endregion #region 變為Models需要之型別及邏輯資料 #endregion #region Models資料庫 this._repository.Delete(query); this._unitOfWork.SaveChange(); #endregion }