private void FixupMy_Products_Services(My_Products_Services previousValue)
        {
            if (previousValue != null && previousValue.EventsInfoes.Contains(this))
            {
                previousValue.EventsInfoes.Remove(this);
            }

            if (My_Products_Services != null)
            {
                if (!My_Products_Services.EventsInfoes.Contains(this))
                {
                    My_Products_Services.EventsInfoes.Add(this);
                }
                if (My_Product_Service_Id != My_Products_Services.Id)
                {
                    My_Product_Service_Id = My_Products_Services.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.
                 */
                //My_Product_Service_Id = null;
            }
        }
Example #2
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);
        }
Example #3
0
        /// <summary>
        ///		No Metadata Documentation available.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="id"></param>
        /// <param name="my_Products_Services"></param>
        /// <returns></returns>
        public static Helpers.ActionResult Get(Helpers.ApiContext apiContext, int id, out Entities.My_Products_Services my_Products_Services)
        {
            // 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.My_Products_Services.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)
                {
                    my_Products_Services = qry;

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

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

            return(result);
        }
Example #4
0
        public static Helpers.ActionResult Add(Helpers.ApiContext apiContext, Entities.My_Products_Services my_Products_Services, 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 (my_Products_Services == 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, my_Products_Services);

                context.AddObject("My_Products_Services", my_Products_Services);

                context.SaveChanges();                 // Save Changes

                id = my_Products_Services.Id;

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

            return(result);
        }
Example #5
0
        public bool Insert(ApiContext apiContext,
                           Entities.Products_Services productService,
                           Entities.Receipt receipt,
                           Entities.WarrantyCard warrantyCard,
                           List <Entities.Image> receiptImageList,
                           List <Entities.Image> warranyCardImageList)
        {
            try
            {
                //Save Product Service
                long serviceId = 0;
                var  result    = CoreManagers.ProductsServicesManager.Add(apiContext, productService, out serviceId);

                //Save receipt
                long receiptId = 0;
                result = CoreManagers.ReceiptManager.Add(apiContext, receipt, out receiptId);

                //Save receipt images

                if (receiptImageList.Count > 0)
                {
                    List <Entities.ReceiptImage> receiptImages = new List <Entities.ReceiptImage>();
                    foreach (Entities.Image image in receiptImageList)
                    {
                        Entities.ReceiptImage receiptImage = new Entities.ReceiptImage();

                        receiptImage.ImageId   = image.Id;
                        receiptImage.ReceiptId = receiptId;

                        receiptImages.Add(receiptImage);
                    }

                    result = CoreManagers.ReceiptimageManager.Add(apiContext, receiptImages);
                }

                //Save receipt
                long warrantyCardId = 0;
                result = CoreManagers.WarrantycardManager.Add(apiContext, warrantyCard, out warrantyCardId);

                //Save warranty card images
                if (warranyCardImageList.Count > 0)
                {
                    List <Entities.WarrantyCardImage> warranyCardImages = new List <Entities.WarrantyCardImage>();
                    foreach (Entities.Image image in warranyCardImageList)
                    {
                        Entities.WarrantyCardImage warrantyCardImage = new Entities.WarrantyCardImage();

                        warrantyCardImage.ImageId        = image.Id;
                        warrantyCardImage.WarrantyCardId = warrantyCardId;

                        warranyCardImages.Add(warrantyCardImage);
                    }

                    result = CoreManagers.WarrantycardimageManager.Add(apiContext, warranyCardImages);
                }

                //Save My Product Service
                Entities.My_Products_Services myProdService = new Entities.My_Products_Services();

                myProdService.Product_Service_Id = serviceId;
                myProdService.ReceiptId          = receiptId;
                myProdService.WarrantyCardId     = warrantyCardId;
                myProdService.CreatedOn          = DateTime.Now;

                result = CoreManagers.MyProductsServicesManager.Add(apiContext, new List <Entities.My_Products_Services> {
                    myProdService
                });

                return(result.WasSuccessful);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
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.My_Products_Services, bool> > whereClause, out Entities.My_Products_Services 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.My_Products_Services.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);
            }
        }
Example #7
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.My_Products_Services my_Products_Services);
Example #8
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);
Example #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.My_Products_Services my_Products_Services, bool isBulkUpdate);