示例#1
0
        public async Task <CommandResult> Handle(DeleteMainTenantCommand message)
        {
            MainTenant mainTenant = new MainTenant();

            mainTenant           = _mapper.Map <DeleteMainTenantCommand, MainTenant>(message);
            mainTenant.RowStatus = false;
            mainTenant.Update(message.UserId);
            if (mainTenant.HasErrors)
            {
                return(mainTenant.ToResult());
            }

            _mainTenantRepository.UpdatePartial(mainTenant, new string[] { "TenantId",
                                                                           "RowStatus",
                                                                           "UpdatedBy",
                                                                           "UpdatedDate" });
            await _unitOfWork.CommitAsync();

            //await _bus.PublishAsync(new MainTenantDeleted() { TenantId = mainTenant.TenantId });

            return(mainTenant.ToResult());
        }
示例#2
0
        public async Task <CommandResult> Handle(UpdateMainTenantCommand message)
        {
            //Validate using domain models
            MainTenant entity = _mapper.Map <UpdateMainTenantCommand, MainTenant>(message);

            //if is not valid
            //if (entity.HasErrors) return entity.ToResult();
            entity.UpdatedBy   = message.UserId;
            entity.UpdatedDate = DateTime.Now;

            _mainTenantRepository.UpdatePartial(entity, new string[] { "TenantId",
                                                                       "Code",
                                                                       "FullName",
                                                                       "CountryId",
                                                                       "PassportNo",
                                                                       "PhoneN01",
                                                                       "Email",
                                                                       "RowStatus",
                                                                       "UpdatedBy",
                                                                       "UpdatedDate",
                                                                       "TypeId",
                                                                       "Address",
                                                                       "Reference",
                                                                       "PhoneNo2",
                                                                       "ContactName",
                                                                       "ContactPhone",
                                                                       "ContactEmail",
                                                                       "ContactRelation",
                                                                       "IdRef" });
            await _unitOfWork.CommitAsync();

            //Publish bussines Event
            //await _bus.PublishAsync(new MainTenantUpdated() { TenantId = entity.TenantId });

            //Return result
            return(entity.ToResult());
        }