/// <summary> /// Delete an entity. /// </summary> /// <param name="model"></param> public void Delete(StockAssessmentPolicyViewModel model) { var entity = model.ToEntity(); this._StockAssessmentPolicysRepository.Delete(entity); #region Commit Changes this._unitOfWork.Commit(); #endregion }
/// <summary> /// Throw an exception if name is exist. /// </summary> /// <param name="model">StockAssessmentPolicy view model</param> public void ThrowExceptionIfExist(StockAssessmentPolicyViewModel model) { ConditionFilter <StockAssessmentPolicy, long> condition = new ConditionFilter <StockAssessmentPolicy, long> { Query = (entity => entity.Name == model.Name && entity.Id != model.Id) }; var existEntity = this._StockAssessmentPolicysRepository.Get(condition).FirstOrDefault(); if (existEntity != null) { throw new ItemAlreadyExistException(); } }
/// <summary> /// Update an entity. /// </summary> /// <param name="model"></param> /// <returns></returns> public StockAssessmentPolicyViewModel Update(StockAssessmentPolicyViewModel model) { this.ThrowExceptionIfExist(model); var entity = model.ToEntity(); entity = this._StockAssessmentPolicysRepository.Update(entity); #region Commit Changes this._unitOfWork.Commit(); #endregion model = entity.ToModel(); return(model); }