/// <summary> /// Update Specific Infomation to Cellar how Min, Max and detail /// </summary> /// <param name="data"></param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> CellarUpdate(tblCellar data) { erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { var row = db.tblCellar.Single(p => p.id == data.id); row.idcellarArea = data.idcellarArea; row.min = data.min; row.max = data.max; row.detail = data.detail; row.upDateDate = data.upDateDate; 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 Amount To ProductID and CellarID From Cellar /// </summary> /// <param name="ProductID">Product ID</param> /// <param name="CellarArea">CellarAreaID</param> /// <returns>Amount from Cellar</returns> public static Tuple <ErrorObject, tblCellar> GetCellarByProductIDAndCellarArea(int ProductID, int CellarAreaID, int conditionID, int transactionTypeID) { tblCellar Amount = new tblCellar(); erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { Amount = ( from TC in db.tblTransactionConfigurate join C in db.tblCellar on TC.idAnchorTransaction equals C.id join T in db.tblTransaction on TC.idTransaction equals T.id where C.idProduct == ProductID && C.idcellarArea == CellarAreaID && TC.idTransactionType == transactionTypeID && T.idConditionProduct == conditionID select C).First(); return(new Tuple <ErrorObject, tblCellar>(erros.IfError(false), Amount)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, tblCellar>(erros, Amount)); } }
/// <summary> /// Insert Cellar Information /// </summary> /// <param name="data">Cellar Information</param> /// <returns>Cellar ID</returns> public static Tuple <ErrorObject, int> Cellar(tblCellar data) { erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { int propertyFind = db.tblCellar.Count(); if (propertyFind > 0) { data.id = db.tblCellar.Max(s => s.id); } else { data.id = 1; } db.tblCellar.Add(data); result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, int>(erros.IfError(false), data.id)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, int>(erros, 0)); } }
private static GetCellarResponse Cellars(GetCellarResponse request) { GetCellarResponse response = new GetCellarResponse(); try { tblCellar bussines = new tblCellar() { id = request.Cellar.id, amount = request.Cellar.amount, detail = request.Cellar.detail, idProduct = request.Cellar.idProduct, idcellarArea = request.Cellar.idcellarArea, createDate = request.Cellar.createDate, upDateDate = DateTime.Now, deleteDate = null, state = "Active" }; var result = CellarData.Update.Cellar(bussines); if (result.Item1.Error) { response.Error.InfoError(result.Item1); } else { response.Message = result.Item2; } } catch (Exception ex) { response.Error.InfoError(ex); } return(response); }
public static GetCellarResponse Cellar(GetCellarResponse request) { GetCellarResponse response = new GetCellarResponse(); response.Error = new Handler.ErrorObject(); try { tblCellar bussines = new tblCellar() { id = request.Cellar.id, detail = request.Cellar.detail, min = request.Cellar.Min, max = request.Cellar.Max, idcellarArea = request.Cellar.idcellarArea, createDate = request.Cellar.createDate, state = "Active" }; var result = CellarData.Update.CellarUpdate(bussines); response.Message = result.Item2.ToString(); } catch (Exception ex) { response.Error.InfoError(ex); } return(response); }
/// <summary> /// Return Cellar Information /// </summary> /// <param name="id">Cellar ID</param> /// <returns>Cellar Information</returns> public static Tuple <ErrorObject, tblCellar> GetCellar(int id) { tblCellar data = new tblCellar(); erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { data = db.tblCellar.Find(id); }; return(new Tuple <ErrorObject, tblCellar>(erros.IfError(false), data)); } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, tblCellar>(erros, data)); } }
/// <summary> /// Return ID To Product ID and Cellar Area ID /// </summary> /// <param name="ProductID"></param> /// <param name="CellarArea"></param> /// <returns></returns> public static Tuple <ErrorObject, tblCellar> GetCellarIDByProductIDAndCellarArea(int ProductID, int CellarAreaID) { tblCellar data = new tblCellar(); erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { data = db.tblCellar.Single(C => C.idProduct == ProductID && C.idcellarArea == CellarAreaID); return(new Tuple <ErrorObject, tblCellar>(erros.IfError(false), data)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, tblCellar>(erros, data)); } }
/// <summary> /// Update Cellar Information /// </summary> /// <param name="data">Cellar Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> Cellar(tblCellar 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 Affected Row Or Error If Exist /// </summary> /// <param name="request">Employee Information</param> /// <returns>Cellar ID</returns> private static GetCellarResponse Cellars(GetCellarResponse request) { GetCellarResponse response = new GetCellarResponse(); response.Error = new Handler.ErrorObject(); try { tblCellar bussines = new tblCellar() { id = request.Cellar.id, amount = request.Cellar.amount, detail = request.Cellar.detail, min = request.Cellar.Min, max = request.Cellar.Max, idProduct = request.Cellar.idProduct, idcellarArea = request.Cellar.idcellarArea, createDate = request.Cellar.createDate, upDateDate = null, deleteDate = null, state = "Active" }; var result = CellarData.Insert.Cellar(bussines); if (result.Item1.Error) { response.Error.InfoError(result.Item1); } else { response.Message = result.Item2.ToString(); } } catch (Exception ex) { response.Error.InfoError(ex); } return(response); }