Пример #1
0
        /// <summary>
        ///		No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="id"></param>
        /// <param name="imageType"></param>
        /// <returns></returns>
        public static Helpers.ActionResult Get(Helpers.ApiContext apiContext, int id, out Entities.ImageType imageType)
        {
            // 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.ImageTypes.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)
                {
                    imageType = qry;

                    // must detach the object before return
                    DetachObject(apiContext, imageType);
                }
                else
                {
                    imageType    = new Entities.ImageType();
                    imageType.Id = id;

                    result.WasSuccessful = false;
                    result.Messages.Add(Helpers.ActionResultMessage.Factory(imageType, "Object not Found", Helpers.ActionResultMessageType.Warning));
                }
            }
            catch (System.Exception ex)
            {
                object forDebugging = ex;
                throw;    // Helpers.Exceptions.GetEntityException.Factory(ex);
            }

            return(result);
        }
Пример #2
0
        public static Helpers.ActionResult Add(Helpers.ApiContext apiContext, Entities.ImageType imageType, 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 (imageType == 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, imageType);

                context.AddObject("ImageTypes", imageType);

                context.SaveChanges();                 // Save Changes

                id = imageType.Id;

                DetachObjects(apiContext, new System.Collections.Generic.List <Entities.ImageType> {
                    imageType
                });                                                                                                              // Clean ObjectState cache
            }
            catch (System.Exception ex)
            {
                object forDebugging = ex;
                throw;                // Helpers.Exceptions.AddEntityException.Factory(ex);
            }

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

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

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

            OnValidated(apiContext, imageType, ref result);
        }
Пример #4
0
        /// <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.ImageType, bool> > whereClause, out Entities.ImageType 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.ImageTypes.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);
            }
        }
Пример #5
0
 //	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.ImageType imageType);
Пример #6
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.ImageType imageType, ref Helpers.ActionResult result);
Пример #7
0
 //	This partial method gives us a way to access an object during it is bulk updated in the system.
 static partial void OnPartialUpdate(Helpers.ApiContext apiContext, Entities.ImageType imageType);
Пример #8
0
 //	This partial method gives us a way to update an object before it is imported into the system.
 static partial void OnImporting(Helpers.ApiContext apiContext, Entities.ImageType imageType);
Пример #9
0
 //	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.ImageType imageType, bool isBulkUpdate);