public async Task <ICommandResult> Handle(LocationRemoveCommand mesage) { try { ICommandResult result; Province province = new Province(); province.Remove(mesage); #region CheckExits if (mesage.TypeLocation == 1) { var location = await _locationService.GetProvinceById(mesage.ProvinceId); if (location == null) { result = new CommandResult() { Message = "Province not found", ObjectId = "", Status = CommandResult.StatusEnum.Fail, ResourceName = ResourceKey.Location_NotFound }; return(result); } await _locationService.ChangeProvinceStatus(mesage.ProvinceId, province.Status, province.UpdatedUid, province.UpdatedDateUtc); } if (mesage.TypeLocation == 2) { var location = await _locationService.GetDistrictById(mesage.DistricId); if (location == null) { result = new CommandResult() { Message = "District not found", ObjectId = "", Status = CommandResult.StatusEnum.Fail, ResourceName = ResourceKey.Location_NotFound }; return(result); } await _locationService.ChangeDistrictStatus(mesage.DistricId, province.Status, province.UpdatedUid, province.UpdatedDateUtc); } if (mesage.TypeLocation == 3) { var location = await _locationService.GetWardById(mesage.WardId); if (location == null) { result = new CommandResult() { Message = "Ward not found", ObjectId = "", Status = CommandResult.StatusEnum.Fail, ResourceName = ResourceKey.Location_NotFound }; return(result); } await _locationService.ChangeWardStatus(mesage.WardId, province.Status, province.UpdatedUid, province.UpdatedDateUtc); } if (mesage.TypeLocation == 4) { var location = await _locationService.GetStreetById(mesage.StreetId); if (location == null) { result = new CommandResult() { Message = "Ward not found", ObjectId = "", Status = CommandResult.StatusEnum.Fail, ResourceName = ResourceKey.Location_NotFound }; return(result); } await _locationService.ChangeStreetStatus(mesage.StreetId, province.Status, province.UpdatedUid, province.UpdatedDateUtc); } #endregion //await _eventSender.Notify(banner.Events); result = new CommandResult() { Message = "", ObjectId = province.Id, Status = CommandResult.StatusEnum.Sucess }; return(result); } catch (Exception e) { e.Data["Param"] = mesage; ICommandResult result = new CommandResult() { Message = e.Message, Status = CommandResult.StatusEnum.Fail }; return(result); } }