Example #1
0
        public void Distinguish_a_value_type_instances_from_one_of_its_derived_type_instance()
        {
            var amount    = new Amount(new decimal(50.3), Currency.Dollar);
            var itemPrice = new ItemPrice("movie", new decimal(50.3), Currency.Dollar);

            Check.That((Amount)itemPrice).IsNotEqualTo(amount);
            Check.That(itemPrice == amount).IsFalse();
            Check.That(itemPrice.Equals(amount)).IsFalse();
            Check.That(itemPrice.Equals((object)amount)).IsFalse();
        }
        /// <summary>
        ///  Update ItemPrice data to ItemPrice Table according to the ItemPrice Parameter
        ///   Return Constants.DB_STATUS
        /// </summary>
        /// <param name="itemPrice"></param>
        /// <returns></returns>
        public Constants.DB_STATUS Update(ItemPrice itemPrice)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            try
            {
                itemPriceObj = inventory.ItemPrices.Where(iObj => iObj.ItemId == itemPrice.ItemId).First();
                if (!itemPriceObj.Equals(null))
                {
                    Employee createdBy = inventory.Employees.Where(eObj => eObj.Id == itemPrice.CreatedBy.Id).First();
                    itemPriceObj.SupplierId  = itemPrice.SupplierId;
                    itemPriceObj.Price       = itemPrice.Price;
                    itemPriceObj.CreatedDate = itemPrice.CreatedDate;
                    itemPriceObj.CreatedBy   = createdBy;
                    inventory.SaveChanges();
                    status = Constants.DB_STATUS.SUCCESSFULL;
                }
            }
            catch (Exception e)
            {
                status = Constants.DB_STATUS.FAILED;
            }

            return(status);
        }