private void FixupSystem_Social_UsersAssociation(System_Social_UsersAssociation previousValue) { if (previousValue != null && ReferenceEquals(previousValue.User, this)) { previousValue.User = null; } if (System_Social_UsersAssociation != null) { System_Social_UsersAssociation.User = this; } }
/// <summary> /// No Metadata Documentation available. /// </summary> /// <param name="apiContext"></param> /// <param name="system_Social_UsersAssociation"></param> /// <param name="result"></param> public static void ValidateData(Helpers.ApiContext apiContext, Entities.System_Social_UsersAssociation system_Social_UsersAssociation, ref Helpers.ActionResult result) { OnValidating(apiContext, system_Social_UsersAssociation, ref result); if (system_Social_UsersAssociation.Id == null) { result.Messages.Add(Helpers.ActionResultMessage.Factory(system_Social_UsersAssociation, "Id is required.", Helpers.ActionResultMessageType.Error)); result.WasSuccessful = false; } OnValidated(apiContext, system_Social_UsersAssociation, ref result); }
/// <summary> /// No Metadata Documentation available. /// </summary> /// <param name="apiContext"></param> /// <param name="id"></param> /// <param name="system_Social_UsersAssociation"></param> /// <returns></returns> public static Helpers.ActionResult Get(Helpers.ApiContext apiContext, int id, out Entities.System_Social_UsersAssociation system_Social_UsersAssociation) { // API doesn't allow null parameters. if (apiContext == null) { throw new System.ArgumentNullException("apiContext"); } if (id == null) { throw new System.ArgumentNullException("id"); } // Verify user is authorized to perform action, otherwise throw exception. Security.SecurityHandler.SetApiContext(apiContext); Helpers.ActionResult result = Helpers.ActionResult.Factory(true); try { Model.OrmsContext context = (Model.OrmsContext)apiContext.CurrentContext; var qry = context.System_Social_UsersAssociation.Where(r => r.Id.Equals(id)).FirstOrDefault(); // See what would be default value in this case // Also to see if no value found what shall be put into Action Result if (qry != null) { system_Social_UsersAssociation = qry; // must detach the object before return DetachObject(apiContext, system_Social_UsersAssociation); } else { system_Social_UsersAssociation = new Entities.System_Social_UsersAssociation(); system_Social_UsersAssociation.Id = id; result.WasSuccessful = false; result.Messages.Add(Helpers.ActionResultMessage.Factory(system_Social_UsersAssociation, "Object not Found", Helpers.ActionResultMessageType.Warning)); } } catch (System.Exception ex) { object forDebugging = ex; throw; // Helpers.Exceptions.GetEntityException.Factory(ex); } return(result); }
public static Helpers.ActionResult Add(Helpers.ApiContext apiContext, Entities.System_Social_UsersAssociation system_Social_UsersAssociation, out long id) { // API doesn't allow null parameters. This method requires at least 1 item in the collection. if (apiContext == null) { throw new System.ArgumentNullException("apiContext"); } if (system_Social_UsersAssociation == null) { throw new System.ArgumentNullException("image"); } // Verify user is authorized to perform action, otherwise throw exception. Security.SecurityHandler.SetApiContext(apiContext); Helpers.ActionResult result = Helpers.ActionResult.Factory(true); try { Model.OrmsContext context = (Model.OrmsContext)apiContext.CurrentContext; // ADD to context OnAdding(apiContext, system_Social_UsersAssociation); context.AddObject("System_Social_UsersAssociation", system_Social_UsersAssociation); context.SaveChanges(); // Save Changes id = system_Social_UsersAssociation.Id; DetachObjects(apiContext, new System.Collections.Generic.List <Entities.System_Social_UsersAssociation> { system_Social_UsersAssociation }); // Clean ObjectState cache } catch (System.Exception ex) { object forDebugging = ex; throw; // Helpers.Exceptions.AddEntityException.Factory(ex); } return(result); }
/// <summary> /// No Metadata Documentation available. /// </summary> /// <param name="apiContext"></param> /// <param name="whereClause"></param> /// <param name="entity"></param> /// <returns></returns> public static bool IsExists(Helpers.ApiContext apiContext, System.Linq.Expressions.Expression <System.Func <Entities.System_Social_UsersAssociation, bool> > whereClause, out Entities.System_Social_UsersAssociation entity) { // API doesn't allow null parameters. This method requires at least 1 item in the collection. if (apiContext == null) { throw new System.ArgumentNullException("apiContext"); } if (whereClause == null) { throw new System.ArgumentNullException("whereClause"); } // Verify user is authorized to perform action, otherwise throw exception. Security.SecurityHandler.SetApiContext(apiContext); try { Model.OrmsContext context = (Model.OrmsContext)apiContext.CurrentContext; var query = context.System_Social_UsersAssociation.Where(whereClause).FirstOrDefault(); if (query != null) { entity = query; DetachObject(apiContext, entity); // must detach the object before return } else { entity = null; } return(query != null); } catch (System.Exception ex) { object forDebugging = ex; throw; // Helpers.Exceptions.ExistsException.Factory(ex); } }
// This partial method gives us a way to access an object after it has been purged from the system. static partial void OnPurged(Helpers.ApiContext apiContext, Entities.System_Social_UsersAssociation system_Social_UsersAssociation);
// This partial method gives us a way to access an object after it has been validated in the system. static partial void OnValidated(Helpers.ApiContext apiContext, Entities.System_Social_UsersAssociation system_Social_UsersAssociation, ref Helpers.ActionResult result);
// This partial method gives us a way to access an object after it has been updated in the system. static partial void OnUpdated(Helpers.ApiContext apiContext, Entities.System_Social_UsersAssociation system_Social_UsersAssociation, bool isBulkUpdate);