public Framework.Common.Service.Message.ResponseDto UpdateAccount(Common.DTO.AccountDto account) { ResponseDto response = new ResponseDto(); AccountToAppDomainTDataAccess accAppDa = new AccountToAppDomainTDataAccess(); var dbAccount = this.GetSingle(it => it.AccountId == account.AccountId); if (dbAccount != null) { List <AccountToAppDomainDto> deletedAppDomain = new List <AccountToAppDomainDto>(); List <AccountToAppDomainDto> insertedAppDomain = new List <AccountToAppDomainDto>(); foreach (var item in account.ApplicationDomainDtoList) { if (item.State == Framework.Common.CommonBase.DtoObjectState.Deleted) { var accApp = accAppDa.GetSingle(it => it.AppDomainId == item.ApplicationDomainId && it.AccountId == account.AccountId); if (accApp != null) { deletedAppDomain.Add(accApp); } } if (item.State == Framework.Common.CommonBase.DtoObjectState.Inserted) { AccountToAppDomainDto newDto = new AccountToAppDomainDto() { AccountId = account.AccountId, AppDomainId = item.ApplicationDomainId }; insertedAppDomain.Add(newDto); } } if (deletedAppDomain.Count > 0) { accAppDa.Delete(deletedAppDomain); } if (insertedAppDomain.Count > 0) { accAppDa.Insert(insertedAppDomain); } dbAccount.Enabled = account.Enabled; dbAccount.Username = account.Username; this.Update(dbAccount); } else { response.Response.AddBusinessException("حساب کاربری موجود نیست!", BusinessExceptionEnum.Validation); } return(response); }
public Framework.Common.Service.Message.ResponseDto DeAssignAccountAppDomain(Common.DTO.AccountDto account, int appDomain) { AccountTDataAccess accountDa = new AccountTDataAccess(); ResponseDto response = new ResponseDto(); var dbAccount = accountDa.GetSingle(it => it.AccountId == account.AccountId); if (dbAccount != null) { AccountToAppDomainTDataAccess accToDomainDa = new AccountToAppDomainTDataAccess(); var dbAccToDomain = accToDomainDa.GetSingle(it => it.AccountId == account.AccountId && it.AppDomainId == appDomain && it.ExpireDate == null); dbAccToDomain.ExpireDate = null; accToDomainDa.Update(dbAccToDomain); } else { response.Response.AddBusinessException("حساب کاربری وجود ندارد!", BusinessExceptionEnum.Operational); } return(response); }