/// <summary>
        /// Delete an entity.
        /// </summary>
        /// <param name="model"></param>
        public void Delete(SalesBillTypeViewModel model)
        {
            var entity = model.ToEntity();

            this._SalesBillTypesRepository.Delete(entity);

            #region Commit Changes
            this._unitOfWork.Commit();
            #endregion
        }
        /// <summary>
        /// Throw an exception if name is exist.
        /// </summary>
        /// <param name="model">SalesBillType view model</param>
        public void ThrowExceptionIfExist(SalesBillTypeViewModel model)
        {
            ConditionFilter <SalesBillType, long> condition = new ConditionFilter <SalesBillType, long>
            {
                Query = (entity =>
                         entity.Name == model.Name &&
                         entity.Id != model.Id)
            };
            var existEntity = this._SalesBillTypesRepository.Get(condition).FirstOrDefault();

            if (existEntity != null)
            {
                throw new ItemAlreadyExistException();
            }
        }
        /// <summary>
        /// Update an entity.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public SalesBillTypeViewModel Update(SalesBillTypeViewModel model)
        {
            this.ThrowExceptionIfExist(model);

            var entity = model.ToEntity();

            entity = this._SalesBillTypesRepository.Update(entity);

            #region Commit Changes
            this._unitOfWork.Commit();
            #endregion

            model = entity.ToModel();
            return(model);
        }