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