/// <summary> /// Insert a <see cref="CellFed"/> passed as an argument via Stored Procedure that returns the newly inserted CellFed Key /// </summary> /// <param name="aCellFed">A <see cref="CellFed"/>.</param> /// <exception cref="ArgumentNullException">If <c>aCellFed</c> argument is <c>null</c>.</exception> public static void Insert(CellFedCollection aCellFedCollection) { if (aCellFedCollection == null) { throw new ArgumentNullException("aCellFedCollection"); } using (var vSqlCommand = new SqlCommand() { CommandType = CommandType.Text, Connection = new SqlConnection(Connection.Instance.SqlConnectionString) }) { var vStringBuilder = new StringBuilder(); vStringBuilder.AppendLine("insert into CED_CellFederation"); vStringBuilder.AppendLine(" (CEL_Key, FED_Key,"); vStringBuilder.AppendLine(" CED_DateJoined)"); vStringBuilder.AppendLine("values"); vStringBuilder.AppendLine(" (@CELKey, @FEDKey,"); vStringBuilder.AppendLine(" @CEDDateJoined)"); vStringBuilder.AppendLine(";"); vSqlCommand.Parameters.Add("@CELKey", SqlDbType.Int); vSqlCommand.Parameters.Add("@FEDKey", SqlDbType.Int); vSqlCommand.Parameters.Add("@CEDDateJoined", SqlDbType.DateTime); vSqlCommand.CommandText = vStringBuilder.ToString(); vSqlCommand.Connection.Open(); aCellFedCollection.CellFedList.ForEach(vCellFed => { vSqlCommand.Parameters["@CELKey"].Value = vCellFed.CelKey; vSqlCommand.Parameters["@FEDKey"].Value = vCellFed.FedKey; vSqlCommand.Parameters["@CEDDateJoined"].Value = vCellFed.CellFedDateJoined; vSqlCommand.ExecuteScalar(); }); vSqlCommand.Connection.Close(); } }
public static webObject loadCellFedCollection(CellFedCollection aCellFedCollection) { FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session); ServerSession.ClearSessionBusiness(HttpContext.Current.Session); webObject vWebObject = new webObject(); vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session); try { FanServiceConsumer.GetCellFedCollection(vFanToken, aCellFedCollection); vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK; vWebObject.aTransactionStatus.Message = "CellFedCollection Loaded"; ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus); vWebObject.AnObject = aCellFedCollection; } catch (TransactionStatusException tx) { vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus); return(vWebObject); } catch (Exception ex) { vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException; vWebObject.aTransactionStatus.Message = "Load of CellFedCollection unsuccesful" + ex.Message; vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message; return(vWebObject); } return(vWebObject); }
/// <summary> /// The overloaded Load method that will fill the <c>CellFedList</c> property a <see cref="CellFedCollection"/> object as an /// ordered <c>List</c> of <see cref="CellFed"/>, filtered by the filter properties of the passed <see cref="CellFedCollection"/>. /// </summary> /// <param name="aCellFedCollection">The <see cref="CellFedCollection"/> object that must be filled.</param> /// <remarks> /// The filter properties of the <see cref="CellFedCollection"/> must be correctly completed by the calling application. /// </remarks> /// <exception cref="ArgumentNullException">If <c>aCellFedCollection</c> argument is <c>null</c>.</exception> public static void Load(CellFedCollection aCellFedCollection) { if (aCellFedCollection == null) { throw new ArgumentNullException("aCellFedCollection"); } using (var vSqlCommand = new SqlCommand() { CommandType = CommandType.Text, Connection = new SqlConnection(Connection.Instance.SqlConnectionString) }) { var vStringBuilder = BuildSQL(); if (aCellFedCollection.IsFiltered) { if (aCellFedCollection.CellFedFilter.CellfedFilter.CelKey > 0) { vStringBuilder.AppendLine("and t1.CEL_Key = @CELKey"); vSqlCommand.Parameters.AddWithValue("@CELKey", aCellFedCollection.CellFedFilter.CellfedFilter.CelKey); } if (aCellFedCollection.CellFedFilter.CellfedFilter.FedKey > 0) { vStringBuilder.AppendLine("and t2.FED_Key = @FEDKey"); vSqlCommand.Parameters.AddWithValue("@FEDKey", aCellFedCollection.CellFedFilter.CellfedFilter.FedKey); } if (aCellFedCollection.CellFedFilter.CellfedFilter.CellName != null) { vStringBuilder.AppendFormat("and t1.CEL_Name like '%{0}%'", aCellFedCollection.CellFedFilter.CellfedFilter.CellName); } if (aCellFedCollection.CellFedFilter.CellfedFilter.FedName != null) { vStringBuilder.AppendFormat("and t2.FED_Name like '%{0}%'", aCellFedCollection.CellFedFilter.CellfedFilter.FedName); } } vStringBuilder.AppendLine("order by t1.CEL_Name"); vSqlCommand.CommandText = vStringBuilder.ToString(); vSqlCommand.Connection.Open(); using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader()) { while (vSqlDataReader.Read()) { var vCellFed = new CellFed(); DataToObject(vCellFed, vSqlDataReader, false); aCellFedCollection.CellFedList.Add(vCellFed); } vSqlDataReader.Close(); } vSqlCommand.Connection.Close(); } }
/// <summary> /// Save a <see cref="CellFed" /> list passed as an argument. /// </summary> /// <param name="aFanKey">A <see cref="FanKey" /> object.</param> /// <param name="aCellFedCollection">A cell fed collection.</param> /// <exception cref="Zephry.ZpAccessException">Access Denied; CellFed</exception> /// <exception cref="ArgumentNullException">If <c>aCellFed</c> argument is <c>null</c>.</exception> public static void Save(FanKey aFanKey, CellFedCollection aCellFedCollection) { if (aCellFedCollection == null) { throw new ArgumentNullException("Update CellFedCollection Business"); } //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "CellFed", AccessMode.Update)) //{ // throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Update, "CellFed"); //} CellFedData.Save(aCellFedCollection); }
public static webObject editCellFedCollection(CellFedCollection aCellFedCollection) { FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session); ServerSession.ClearSessionBusiness(HttpContext.Current.Session); webObject vWebObject = new webObject(); vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session); // ********** TEMPORARY REMEDY UNTIL I SORT OUT DATETIME ISSUE foreach (CellFed vCF in aCellFedCollection.CellFedList) { vCF.CellFedDateJoined = DateTime.Now; } try { FanServiceConsumer.SaveCellFed(vFanToken, aCellFedCollection); vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK; vWebObject.aTransactionStatus.Message = "CellFedCollection Edited"; ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus); vWebObject.AnObject = aCellFedCollection; } catch (TransactionStatusException tx) { vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus); return(vWebObject); } catch (Exception ex) { vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException; vWebObject.aTransactionStatus.Message = "Edit of CellFedCollection unsuccesful" + ex.Message; vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message; return(vWebObject); } return(vWebObject); }
/// <summary> /// Gets a specified <see cref="CellFedCollection"/>. /// </summary> /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param> /// <param name="aCellFedCollection"><see cref="CellFed"/>Collection object.</param> public static void GetCellFedCollection(FanToken aFanToken, CellFedCollection aCellFedCollection) { FanCallHandler.ServiceCall <CellFedCollection>(aFanToken, "GetCellFedCollection", aCellFedCollection); }
public static webObject editCellFedCollection(CellFedCollection aCellFedCollection) { FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session); ServerSession.ClearSessionBusiness(HttpContext.Current.Session); webObject vWebObject = new webObject(); vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session); // ********** TEMPORARY REMEDY UNTIL I SORT OUT DATETIME ISSUE foreach (CellFed vCF in aCellFedCollection.CellFedList) { vCF.CellFedDateJoined = DateTime.Now; } try { FanServiceConsumer.SaveCellFed(vFanToken, aCellFedCollection); vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK; vWebObject.aTransactionStatus.Message = "CellFedCollection Edited"; ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus); vWebObject.AnObject = aCellFedCollection; } catch (TransactionStatusException tx) { vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus); return vWebObject; } catch (Exception ex) { vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException; vWebObject.aTransactionStatus.Message = "Edit of CellFedCollection unsuccesful" + ex.Message; vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message; return vWebObject; } return vWebObject; }
/// <summary> /// Add a <see cref="CellFed" />. /// </summary> /// <param name="aFanToken">A <see cref="FanToken" /> object used for Access Control.</param> /// <param name="aCellFedCollection">A provider suburb collection.</param> public static void SaveCellFed(FanToken aFanToken, CellFedCollection aCellFedCollection) { FanCallHandler.ServiceCall<CellFedCollection>(aFanToken, "SaveCellFed", aCellFedCollection); }
public static webObject loadCellFedCollection(CellFedCollection aCellFedCollection) { FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session); ServerSession.ClearSessionBusiness(HttpContext.Current.Session); webObject vWebObject = new webObject(); vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session); try { FanServiceConsumer.GetCellFedCollection(vFanToken, aCellFedCollection); vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK; vWebObject.aTransactionStatus.Message = "CellFedCollection Loaded"; ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus); vWebObject.AnObject = aCellFedCollection; } catch (TransactionStatusException tx) { vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus); return vWebObject; } catch (Exception ex) { vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException; vWebObject.aTransactionStatus.Message = "Load of CellFedCollection unsuccesful" + ex.Message; vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message; return vWebObject; } return vWebObject; }
/// <summary> /// The <c>GetCellFedCollection</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="CellFedCollection"/> object. /// It invokes the <c>Insert</c> method of <see cref="CellFedBusiness"/> with the newly deserialized <see cref="CellFedCollection"/> object. /// Finally, it returns the collection object as a serialized <see cref="string"/> of XML. /// </summary> /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param> /// <returns><see cref="CellFedCollection"/> as XML <see cref="string"/>.</returns> /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception> public static string GetCellFedCollection(FanKey aFanKey, string aXmlArgument) { if (aXmlArgument == null) { throw new ArgumentNullException("aXmlArgument of GetCellFedCollection"); } CellFedCollection vCellFedCollection = new CellFedCollection(); vCellFedCollection = XmlUtils.Deserialize<CellFedCollection>(aXmlArgument); CellFedBusiness.Load(aFanKey, vCellFedCollection); return XmlUtils.Serialize<CellFedCollection>(vCellFedCollection, true); }
public static void Save(CellFedCollection aCellFedCollection) { Delete(aCellFedCollection.CellFedFilter.CellfedFilter); Insert(aCellFedCollection); }
/// <summary> /// Add a <see cref="CellFed" />. /// </summary> /// <param name="aFanToken">A <see cref="FanToken" /> object used for Access Control.</param> /// <param name="aCellFedCollection">A provider suburb collection.</param> public static void SaveCellFed(FanToken aFanToken, CellFedCollection aCellFedCollection) { FanCallHandler.ServiceCall <CellFedCollection>(aFanToken, "SaveCellFed", aCellFedCollection); }
/// <summary> /// Gets a specified <see cref="CellFedCollection"/>. /// </summary> /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param> /// <param name="aCellFedCollection"><see cref="CellFed"/>Collection object.</param> public static void GetCellFedCollection(FanToken aFanToken, CellFedCollection aCellFedCollection) { FanCallHandler.ServiceCall<CellFedCollection>(aFanToken, "GetCellFedCollection", aCellFedCollection); }