public RequisitionCollectionItem GetRequisitionCollectionItem(RequisitionCollectionItem requisitionCollectionItem)
        {
            reqCollectionItem = inventory.RequisitionCollectionItems.Where(r => r.Id == requisitionCollectionItem.Id).First();

            if (!reqCollectionItem.Equals(null))
            {
                Item item = inventory.Items.Where(i => i.Id == reqCollectionItem.Item.Id).First();
                // int i=Convert.ToInt32(inventory.Items.Last().Id) + 1;
                reqCollectionItem.Item = item;
                return reqCollectionItem;
            }
            return null;
        }
        public Constants.DB_STATUS Insert(RequisitionCollectionItem newRequisitionCollectionItem)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            try
            {

                inventory.AddToRequisitionCollectionItems(newRequisitionCollectionItem);
                inventory.SaveChanges();
                status = Constants.DB_STATUS.SUCCESSFULL;
            }
            catch (Exception e)
            {
                status = Constants.DB_STATUS.FAILED;
            }

            return status;
        }
        public Constants.DB_STATUS Delete(RequisitionCollectionItem requisitionCollectionItem)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            try
            {

                reqCollectionItem = inventory.RequisitionCollectionItems.Where(r => r.Id == requisitionCollectionItem.Id).First();
                reqCollectionItem.Status = 2;
                inventory.SaveChanges();
                status = Constants.DB_STATUS.SUCCESSFULL;
            }
            catch (Exception e)
            {
                status = Constants.DB_STATUS.FAILED;
            }

            return status;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the RequisitionCollectionItems EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRequisitionCollectionItems(RequisitionCollectionItem requisitionCollectionItem)
 {
     base.AddObject("RequisitionCollectionItems", requisitionCollectionItem);
 }
 /// <summary>
 /// Create a new RequisitionCollectionItem object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static RequisitionCollectionItem CreateRequisitionCollectionItem(global::System.Int32 id, global::System.DateTime createdDate, global::System.Int32 status)
 {
     RequisitionCollectionItem requisitionCollectionItem = new RequisitionCollectionItem();
     requisitionCollectionItem.Id = id;
     requisitionCollectionItem.CreatedDate = createdDate;
     requisitionCollectionItem.Status = status;
     return requisitionCollectionItem;
 }
        public Constants.DB_STATUS Update(RequisitionCollectionItem requisitionCollectionItem)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            try
            {

                reqCollectionItem = inventory.RequisitionCollectionItems.Where(r => r.Id == requisitionCollectionItem.Id).First();
                reqCollectionItem.RequisitionCollection = requisitionCollectionItem.RequisitionCollection;
                reqCollectionItem.Item = requisitionCollectionItem.Item;
                reqCollectionItem.CreatedDate = requisitionCollectionItem.CreatedDate;
                reqCollectionItem.CreatedBy = requisitionCollectionItem.CreatedBy;
                reqCollectionItem.Qty = requisitionCollectionItem.Qty;
                inventory.SaveChanges();
                status = Constants.DB_STATUS.SUCCESSFULL;
            }
            catch (Exception e)
            {
                status = Constants.DB_STATUS.FAILED;
            }

            return status;
        }
        /// <summary>
        /// Update the RequisitionCollectionItem data from the parameter
        /// </summary>
        /// <param name="requisitionCollectionItem"></param>
        /// <returns>
        /// Return DB_STATUS
        /// </returns>
        public Constants.DB_STATUS Update(RequisitionCollectionItem requisitionCollectionItem)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            try
            {

                requisitionCollectionItemObj = inventory.RequisitionCollectionItems.Where(r => r.Id == requisitionCollectionItem.Id).First();
                if (!requisitionCollectionItemObj.Equals(null))
                {
                    RequisitionCollection requisitionCollectionId = inventory.RequisitionCollections.Where(r => r.Id == requisitionCollectionItem.RequisitionCollection.Id).First();
                    Item item = inventory.Items.Where(i => i.Id == requisitionCollectionItem.Item.Id).First();
                    Employee createdBy = inventory.Employees.Where(e => e.Id == requisitionCollectionItem.CreatedBy.Id).First();

                    requisitionCollectionItemObj.Id = requisitionCollectionItem.Id;
                    requisitionCollectionItemObj.RequisitionCollection = requisitionCollectionId;
                    requisitionCollectionItemObj.Item = item;
                    requisitionCollectionItemObj.CreatedDate = requisitionCollectionItem.CreatedDate;
                    requisitionCollectionItemObj.CreatedBy = createdBy;
                    requisitionCollectionItemObj.Qty = requisitionCollectionItem.Qty;
                    inventory.SaveChanges();
                    status = Constants.DB_STATUS.SUCCESSFULL;
                }
            }
            catch (Exception e)
            {
                status = Constants.DB_STATUS.FAILED;
            }

            return status;
        }