Пример #1
0
 //	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.PeriodType periodType, ref Helpers.ActionResult result);
Пример #2
0
        /// <summary>
        ///		No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="periodTypes"></param>
        /// <returns></returns>
        public static Helpers.ActionResult BulkUpdate(Helpers.ApiContext apiContext, System.Collections.Generic.IEnumerable <Entities.PeriodType> periodTypes)
        {
            // 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 (periodTypes == null)
            {
                throw new System.ArgumentNullException("periodTypes");
            }
            if (periodTypes.Count() == 0)
            {
                throw new System.ArgumentOutOfRangeException("periodTypes");
            }

            // 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;

                OnBulkUpdating(apiContext, periodTypes);

                foreach (Entities.PeriodType periodType in periodTypes)
                {
                    OnUpdating(apiContext, periodType, true);

                    // ATTACH object
                    AttachObject(apiContext, "PeriodTypes", periodType);

                    // SET system level properties
                    SetSystemProperties(apiContext, periodType);
                    SetSystemPropertiesModified(apiContext, periodType);

                    // PARTIAL update
                    OnPartialUpdate(apiContext, periodType);
                }

                context.SaveChanges();                  // Save Changes
                DetachObjects(apiContext, periodTypes); // Clean ObjectState cache

                foreach (Entities.PeriodType periodType in periodTypes)
                {
                    OnUpdated(apiContext, periodType, true);
                }

                OnBulkUpdated(apiContext, periodTypes);
            }
            catch (System.Data.OptimisticConcurrencyException ex)
            {
                object forDebugging = ex;
                HandleOptimisticConcurrencyException(apiContext, periodTypes, ex, ref result);
                //throw Helpers.Exceptions.OptimisticConcurrencyException.Factory(ex);
            }
            catch (System.Exception ex)
            {
                object forDebugging = ex;
                throw;    // Helpers.Exceptions.UpdateEntityException.Factory(ex);
            }

            return(result);
        }
Пример #3
0
 //	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.My_Products_Services my_Products_Services, ref Helpers.ActionResult result);
Пример #4
0
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="my_Products_Services"></param>
        /// <param name="result"></param>
        public static void ValidateData(Helpers.ApiContext apiContext, Entities.My_Products_Services my_Products_Services, ref Helpers.ActionResult result)
        {
            OnValidating(apiContext, my_Products_Services, ref result);

            if (my_Products_Services.Id == null)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(my_Products_Services, "Id is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }


            OnValidated(apiContext, my_Products_Services, ref result);
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="receipts"></param>
        /// <param name="columnExpression"></param>
        /// <returns></returns>
        public static Helpers.ActionResult PartialUpdate(Helpers.ApiContext apiContext, System.Collections.Generic.IEnumerable <Entities.Receipt> receipts, params System.Linq.Expressions.Expression <System.Func <Entities.Receipt, object> >[] columnExpression)
        {
            // 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 (receipts == null)
            {
                throw new System.ArgumentNullException("receipts");
            }
            if (receipts.Count() == 0)
            {
                throw new System.ArgumentOutOfRangeException("receipts");
            }
            if (columnExpression == null)
            {
                throw new System.ArgumentNullException("columnExpression");
            }
            if (columnExpression.Count() == 0)
            {
                throw new System.ArgumentOutOfRangeException("columnExpression");
            }

            ValidateColumnExpression <Entities.Receipt>(columnExpression);

            Helpers.ActionResult result = Helpers.ActionResult.Factory(true);
            try
            {
                Model.OrmsContext context = (Model.OrmsContext)apiContext.CurrentContext;

                foreach (Entities.Receipt receipt in receipts)
                {
                    // ATTACH object
                    AttachObject(apiContext, "Receipts", receipt);

                    // SET system level properties
                    SetSystemProperties(apiContext, receipt);
                    SetSystemPropertiesModified(apiContext, receipt);

                    // SET IsActive property modified
                    System.Data.Objects.ObjectStateEntry ose = apiContext.CurrentContext.ObjectStateManager.GetObjectStateEntry(receipt);

                    foreach (var item in columnExpression)
                    {
                        ose.SetModifiedProperty(item.GetPropertyName());
                    }
                }

                context.SaveChanges();                 // Save Changes
                DetachObjects(apiContext, receipts);   // Clean ObjectState cache
            }
            catch (System.Data.OptimisticConcurrencyException ex)
            {
                object forDebugging = ex;
                HandleOptimisticConcurrencyException(apiContext, receipts, ex, ref result);
            }
            catch (System.Exception ex)
            {
                object forDebugging = ex;
                throw;    // Helpers.Exceptions.UpdateEntityException.Factory(ex);
            }

            return(result);
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="eventStatus"></param>
        /// <param name="result"></param>
        public static void ValidateData(Helpers.ApiContext apiContext, Entities.EventStatus eventStatus, ref Helpers.ActionResult result)
        {
            OnValidating(apiContext, eventStatus, ref result);

            if (eventStatus.Id == null)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(eventStatus, "Id is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            if (!System.String.IsNullOrWhiteSpace(eventStatus.EventStatus1) && eventStatus.EventStatus1.Length > 50)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(eventStatus, "EventStatus1 must be 50 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(eventStatus.EventStatus1) && !System.Text.RegularExpressions.Regex.IsMatch(eventStatus.EventStatus1, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(eventStatus, "EventStatus1 contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            OnValidated(apiContext, eventStatus, ref result);
        }
Пример #7
0
 //	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_Images product_Service_Images, ref Helpers.ActionResult result);
Пример #8
0
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="receiptImage"></param>
        /// <param name="result"></param>
        public static void ValidateData(Helpers.ApiContext apiContext, Entities.ReceiptImage receiptImage, ref Helpers.ActionResult result)
        {
            OnValidating(apiContext, receiptImage, ref result);

            if (receiptImage.Id == null)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(receiptImage, "Id is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }


            OnValidated(apiContext, receiptImage, ref result);
        }
 //	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.WarrantyCard warrantyCard, ref Helpers.ActionResult result);
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="warrantyCard"></param>
        /// <param name="result"></param>
        public static void ValidateData(Helpers.ApiContext apiContext, Entities.WarrantyCard warrantyCard, ref Helpers.ActionResult result)
        {
            OnValidating(apiContext, warrantyCard, ref result);

            if (warrantyCard.Id == null)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(warrantyCard, "Id is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            if (!System.String.IsNullOrWhiteSpace(warrantyCard.Title) && warrantyCard.Title.Length > 50)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(warrantyCard, "Title must be 50 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(warrantyCard.Title) && !System.Text.RegularExpressions.Regex.IsMatch(warrantyCard.Title, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(warrantyCard, "Title contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(warrantyCard.Description) && warrantyCard.Description.Length > 100)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(warrantyCard, "Description must be 100 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(warrantyCard.Description) && !System.Text.RegularExpressions.Regex.IsMatch(warrantyCard.Description, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(warrantyCard, "Description contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(warrantyCard.CardNumber) && warrantyCard.CardNumber.Length > 0)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(warrantyCard, "CardNumber must be 0 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(warrantyCard.CardNumber) && !System.Text.RegularExpressions.Regex.IsMatch(warrantyCard.CardNumber, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(warrantyCard, "CardNumber contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            OnValidated(apiContext, warrantyCard, ref result);
        }
Пример #11
0
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="products_Services"></param>
        /// <param name="result"></param>
        public static void ValidateData(Helpers.ApiContext apiContext, Entities.Products_Services products_Services, ref Helpers.ActionResult result)
        {
            OnValidating(apiContext, products_Services, ref result);

            if (products_Services.Id == null)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(products_Services, "Id is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            if (System.String.IsNullOrWhiteSpace(products_Services.Name))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(products_Services, "Name is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            if (!System.String.IsNullOrWhiteSpace(products_Services.Name) && products_Services.Name.Length > 50)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(products_Services, "Name must be 50 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(products_Services.Name) && !System.Text.RegularExpressions.Regex.IsMatch(products_Services.Name, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(products_Services, "Name contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(products_Services.Description) && products_Services.Description.Length > 100)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(products_Services, "Description must be 100 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(products_Services.Description) && !System.Text.RegularExpressions.Regex.IsMatch(products_Services.Description, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(products_Services, "Description contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(products_Services.Tags) && !System.Text.RegularExpressions.Regex.IsMatch(products_Services.Tags, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(products_Services, "Tags contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            OnValidated(apiContext, products_Services, ref result);
        }
Пример #12
0
        /// <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);
        }
Пример #13
0
 //	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);
Пример #14
0
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="periodType"></param>
        /// <param name="result"></param>
        public static void ValidateData(Helpers.ApiContext apiContext, Entities.PeriodType periodType, ref Helpers.ActionResult result)
        {
            OnValidating(apiContext, periodType, ref result);

            if (periodType.Id == null)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(periodType, "Id is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            if (!System.String.IsNullOrWhiteSpace(periodType.Title) && periodType.Title.Length > 50)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(periodType, "Title must be 50 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(periodType.Title) && !System.Text.RegularExpressions.Regex.IsMatch(periodType.Title, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(periodType, "Title contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            OnValidated(apiContext, periodType, ref result);
        }
Пример #15
0
 //	This partial method gives us a way to access an object before it is validated in the system.
 static partial void OnValidating(Helpers.ApiContext apiContext, Entities.Role role, ref Helpers.ActionResult result);
Пример #16
0
 //	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.ReceiptImage receiptImage, ref Helpers.ActionResult result);
Пример #17
0
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="user"></param>
        /// <param name="result"></param>
        public static void ValidateData(Helpers.ApiContext apiContext, Entities.User user, ref Helpers.ActionResult result)
        {
            OnValidating(apiContext, user, ref result);

            if (user.Id == null)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "Id is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            if (!System.String.IsNullOrWhiteSpace(user.FirstName) && user.FirstName.Length > 50)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "FirstName must be 50 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(user.FirstName) && !System.Text.RegularExpressions.Regex.IsMatch(user.FirstName, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "FirstName contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(user.LastName) && user.LastName.Length > 50)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "LastName must be 50 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(user.LastName) && !System.Text.RegularExpressions.Regex.IsMatch(user.LastName, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "LastName contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (System.String.IsNullOrWhiteSpace(user.Email))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "Email is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            if (!System.String.IsNullOrWhiteSpace(user.Email) && user.Email.Length > 50)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "Email must be 50 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(user.Email) && !System.Text.RegularExpressions.Regex.IsMatch(user.Email, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "Email contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (System.String.IsNullOrWhiteSpace(user.Password))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "Password is required.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            if (!System.String.IsNullOrWhiteSpace(user.Password) && user.Password.Length > 50)
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "Password must be 50 characters or less.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }
            if (!System.String.IsNullOrWhiteSpace(user.Password) && !System.Text.RegularExpressions.Regex.IsMatch(user.Password, alphaNumeric))
            {
                result.Messages.Add(Helpers.ActionResultMessage.Factory(user, "Password contains invalid characters.", Helpers.ActionResultMessageType.Error));
                result.WasSuccessful = false;
            }

            OnValidated(apiContext, user, ref result);
        }
 /// <summary>
 /// HandleOptimisticConcurrencyException
 /// </summary>
 /// <param name="apiContext"></param>
 /// <param name="receipts"></param>
 /// <param name="exception"></param>
 /// <param name="result"></param>
 public static void HandleOptimisticConcurrencyException(Helpers.ApiContext apiContext, System.Collections.Generic.IEnumerable <Entities.Receipt> receipts, System.Exception exception, ref Helpers.ActionResult result)
 {
     result.Messages.Add(Helpers.ActionResultMessage.Factory(null, Helpers.ActionResultMessageCode.VLD_013, Helpers.ActionResultMessageType.Error));
     result.WasSuccessful = false;
 }
Пример #19
0
 //	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.User user, ref Helpers.ActionResult result);
        /// <summary>
        ///		No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="receipts"></param>
        /// <param name="clientWins">if true system properties will not be overwritten by Api</param>
        /// <returns></returns>
        public static Helpers.ActionResult Update(Helpers.ApiContext apiContext, System.Collections.Generic.IEnumerable <Entities.Receipt> receipts, System.Boolean clientWins)
        {
            // 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 (receipts == null)
            {
                throw new System.ArgumentNullException("receipts");
            }
            if (receipts.Count() == 0)
            {
                throw new System.ArgumentOutOfRangeException("receipts");
            }

            // 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;
                foreach (Entities.Receipt receipt in receipts)
                {
                    OnUpdating(apiContext, receipt, false);

                    // ATTACH object
                    AttachObject(apiContext, "Receipts", receipt);

                    if (!clientWins)
                    {
                        // SET system level properties
                        SetSystemProperties(apiContext, receipt);
                    }

                    // SET modified
                    SetModified(apiContext, receipt);
                }

                if (clientWins)
                {
                    context.Refresh(System.Data.Objects.RefreshMode.ClientWins, receipts);
                }

                context.SaveChanges();                 // Save Changes
                DetachObjects(apiContext, receipts);   // Clean ObjectState cache

                foreach (Entities.Receipt receipt in receipts)
                {
                    OnUpdated(apiContext, receipt, false);
                }
            }
            catch (System.Data.OptimisticConcurrencyException ex)
            {
                object forDebugging = ex;
                HandleOptimisticConcurrencyException(apiContext, receipts, ex, ref result);
                //throw Helpers.Exceptions.OptimisticConcurrencyException.Factory(ex);
            }
            catch (System.Exception ex)
            {
                object forDebugging = ex;
                throw;    // Helpers.Exceptions.UpdateEntityException.Factory(ex);
            }

            return(result);
        }
 //	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.EventStatus eventStatus, ref Helpers.ActionResult result);