/// <summary> /// Return Affected Row Or Error If Exist /// </summary> /// <param name="request">CellarArea Information</param> /// <returns>Affected Row Or Error If Exist</returns> public static GetCellarAreaResponse CellarArea(GetCellarAreaResponse request) { GetCellarAreaResponse response = new GetCellarAreaResponse(); response.Error = new Handler.ErrorObject(); try { tblCellarArea CellarArea = new tblCellarArea() { id = request.CellarArea.id, name = request.CellarArea.name, detail = request.CellarArea.detail, createDate = request.CellarArea.createDate, upDateDate = DateTime.Now, deleteDate = null, state = "Active" }; var result = CellarAreaData.Update.CellarArea(CellarArea); if (result.Item1.Error) { response.Error.InfoError(result.Item1); } else { response.Message = result.Item2; } } catch (Exception ex) { response.Error.InfoError(ex); } return(response); }
/// <summary> /// Insert Cellar Area Information /// </summary> /// <param name="data">Cellar Area Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> CellarArea(tblCellarArea data) { erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { int propertyFind = db.tblCellarArea.Count(); if (propertyFind > 0) { data.id = db.tblCellarArea.Max(s => s.id); } else { data.id = 1; } db.tblCellarArea.Add(data); result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
/// <summary> /// Update Cellar Area Information /// </summary> /// <param name="data">Cellar Area Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> CellarArea(tblCellarArea data) { erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { db.Entry(data).State = EntityState.Modified; result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
/// <summary> /// Return Cellar Area Name /// </summary> /// <param name="id">CellarAreaID</param> /// <returns>Cellar Area Name</returns> public static Tuple <ErrorObject, tblCellarArea> GetCellarAreaName(int id) { tblCellarArea CellarArea = new tblCellarArea(); erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { CellarArea.name = db.tblCellarArea.Find(id).name; } erros.Error = false; return(new Tuple <ErrorObject, tblCellarArea>(erros.IfError(false), CellarArea)); } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, tblCellarArea>(erros, CellarArea)); } }
/// <summary> /// Update Cellar Area Information /// </summary> /// <param name="data">Cellar Area Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> CellarArea(tblCellarArea data) { erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { var row = db.tblCellarArea.Single(p => p.id == data.id); row.name = data.name; row.detail = data.detail; row.upDateDate = data.upDateDate; result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); erros.Error = false; return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }