예제 #1
0
        /// <summary>
        /// Delete an entity.
        /// </summary>
        /// <param name="model"></param>
        public void Delete(InventoryOutViewModel model)
        {
            var entity = model.ToEntity();

            this._InventoryOutsRepository.Delete(entity);

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

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

            var entity = model.ToEntity();

            entity = this._InventoryOutsRepository.Update(entity);

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

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