コード例 #1
0
        /// <summary>
        /// Delete an entity.
        /// </summary>
        /// <param name="model"></param>
        public void Delete(CountryCallingCodeViewModel model)
        {
            var entity = model.ToEntity();

            this._CountryCallingCodesRepository.Delete(entity);

            #region Commit Changes
            this._unitOfWork.Commit();
            #endregion
        }
コード例 #2
0
        /// <summary>
        /// Throw an exception if name is exist.
        /// </summary>
        /// <param name="model">CountryCallingCode view model</param>
        public void ThrowExceptionIfExist(CountryCallingCodeViewModel model)
        {
            ConditionFilter <CountryCallingCode, long> condition = new ConditionFilter <CountryCallingCode, long>
            {
                Query = (entity =>
                         entity.Name == model.Name &&
                         entity.Id != model.Id)
            };
            var existEntity = this._CountryCallingCodesRepository.Get(condition).FirstOrDefault();

            if (existEntity != null)
            {
                throw new ItemAlreadyExistException();
            }
        }
コード例 #3
0
        /// <summary>
        /// Update an entity.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public CountryCallingCodeViewModel Update(CountryCallingCodeViewModel model)
        {
            this.ThrowExceptionIfExist(model);

            var entity = model.ToEntity();

            entity = this._CountryCallingCodesRepository.Update(entity);

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

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