public async Task <KeyValuePair <bool, Place> > Update(int id, Place itemToUpdate) { try { if (itemToUpdate != null && id != default) { itemToUpdate.Id = id; PlaceEntity entity = itemToUpdate.CreateEntity(); var result = this.picturePlaceBusiness.ValidateList(itemToUpdate.ListPicturePlace, itemToUpdate); if (itemToUpdate.ValidationService.Validate(entity) && result.Key) { if (entity.Id != default) { entity = await this.dataAccess.Update(entity, entity.Id); var resultFromPicturePlace = await this.picturePlaceBusiness.CreateOrUpdateFromList(id, itemToUpdate.ListPicturePlace); if (!resultFromPicturePlace.Key) { await this.Delete(entity.Id); itemToUpdate.ValidationService.AddError(nameof(PlaceValidationResources.ListPicturePlace_GoneWrong), PlaceValidationResources.ListPicturePlace_GoneWrong); return(new KeyValuePair <bool, Place>(false, itemToUpdate)); } itemToUpdate = await this.GetPlaceFromEntity(entity); return(new KeyValuePair <bool, Place>(true, itemToUpdate)); } } itemToUpdate = result.Value; } return(new KeyValuePair <bool, Place>(false, itemToUpdate)); } catch (Exception) { return(new KeyValuePair <bool, Place>(false, itemToUpdate)); } }