private void FixupProduct_Service_Sections(Product_Service_Sections previousValue) { if (previousValue != null && previousValue.My_Products_Services.Contains(this)) { previousValue.My_Products_Services.Remove(this); } if (Product_Service_Sections != null) { if (!Product_Service_Sections.My_Products_Services.Contains(this)) { Product_Service_Sections.My_Products_Services.Add(this); } if (SectionId != Product_Service_Sections.Id) { SectionId = Product_Service_Sections.Id; } } else if (!_settingFK) { /* [NOTE] -- * I have commented following, as in case of detaching entities from ObjectState it was making EntityId Null into referenced entities, * which is not desired behavior for us. */ //SectionId = null; } }
/// <summary> /// No Metadata Documentation available. /// </summary> /// <param name="apiContext"></param> /// <param name="product_Service_Sections"></param> /// <param name="result"></param> public static void ValidateData(Helpers.ApiContext apiContext, Entities.Product_Service_Sections product_Service_Sections, ref Helpers.ActionResult result) { OnValidating(apiContext, product_Service_Sections, ref result); if (product_Service_Sections.Id == null) { result.Messages.Add(Helpers.ActionResultMessage.Factory(product_Service_Sections, "Id is required.", Helpers.ActionResultMessageType.Error)); result.WasSuccessful = false; } if (!System.String.IsNullOrWhiteSpace(product_Service_Sections.Name) && product_Service_Sections.Name.Length > 10) { result.Messages.Add(Helpers.ActionResultMessage.Factory(product_Service_Sections, "Name must be 10 characters or less.", Helpers.ActionResultMessageType.Error)); result.WasSuccessful = false; } if (!System.String.IsNullOrWhiteSpace(product_Service_Sections.Name) && !System.Text.RegularExpressions.Regex.IsMatch(product_Service_Sections.Name, alphaNumeric)) { result.Messages.Add(Helpers.ActionResultMessage.Factory(product_Service_Sections, "Name contains invalid characters.", Helpers.ActionResultMessageType.Error)); result.WasSuccessful = false; } if (!System.String.IsNullOrWhiteSpace(product_Service_Sections.Description) && product_Service_Sections.Description.Length > 100) { result.Messages.Add(Helpers.ActionResultMessage.Factory(product_Service_Sections, "Description must be 100 characters or less.", Helpers.ActionResultMessageType.Error)); result.WasSuccessful = false; } if (!System.String.IsNullOrWhiteSpace(product_Service_Sections.Description) && !System.Text.RegularExpressions.Regex.IsMatch(product_Service_Sections.Description, alphaNumeric)) { result.Messages.Add(Helpers.ActionResultMessage.Factory(product_Service_Sections, "Description contains invalid characters.", Helpers.ActionResultMessageType.Error)); result.WasSuccessful = false; } OnValidated(apiContext, product_Service_Sections, ref result); }
/// <summary> /// No Metadata Documentation available. /// </summary> /// <param name="apiContext"></param> /// <param name="id"></param> /// <param name="product_Service_Sections"></param> /// <returns></returns> public static Helpers.ActionResult Get(Helpers.ApiContext apiContext, int id, out Entities.Product_Service_Sections product_Service_Sections) { // 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.Product_Service_Sections.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) { product_Service_Sections = qry; // must detach the object before return DetachObject(apiContext, product_Service_Sections); } else { product_Service_Sections = new Entities.Product_Service_Sections(); product_Service_Sections.Id = id; result.WasSuccessful = false; result.Messages.Add(Helpers.ActionResultMessage.Factory(product_Service_Sections, "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.Product_Service_Sections product_Service_Sections, 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 (product_Service_Sections == 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, product_Service_Sections); context.AddObject("Product_Service_Sections", product_Service_Sections); context.SaveChanges(); // Save Changes id = product_Service_Sections.Id; DetachObjects(apiContext, new System.Collections.Generic.List <Entities.Product_Service_Sections> { product_Service_Sections }); // 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.Product_Service_Sections, bool> > whereClause, out Entities.Product_Service_Sections 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.Product_Service_Sections.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.Product_Service_Sections product_Service_Sections);
// 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.Product_Service_Sections product_Service_Sections, 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.Product_Service_Sections product_Service_Sections, bool isBulkUpdate);